Add webpack

This commit is contained in:
tkqubo
2015-09-22 18:42:55 +09:00
parent 32029fcb4e
commit d12ff571bf
2 changed files with 100 additions and 0 deletions

47
webpack/webpack-tests.ts Normal file
View File

@@ -0,0 +1,47 @@
/// <reference path="webpack.d.ts" />
import webpack from 'webpack';
//import webpack = require('webpack');
var configuration: webpack.Configuration;
var loader: webpack.Loader;
var plugin: webpack.Plugin;
//
// https://webpack.github.io/docs/using-loaders.html
//
configuration = {
module: {
loaders: [
{ test: /\.jade$/, loader: "jade" },
// => "jade" loader is used for ".jade" files
{ test: /\.css$/, loader: "style!css" },
// => "style" and "css" loader is used for ".css" files
// Alternative syntax:
{ test: /\.css$/, loaders: ["style", "css"] },
]
}
};
loader = { test: /\.png$/, loader: "url-loader?mimetype=image/png" };
loader = {
test: /\.png$/,
loader: "url-loader",
query: { mimetype: "image/png" }
};
//
// https://webpack.github.io/docs/using-plugins.html
//
configuration = {
plugins: [
new webpack.ResolverPlugin([
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
], ["normal", "loader"])
]
};

53
webpack/webpack.d.ts vendored Normal file
View File

@@ -0,0 +1,53 @@
// Type definitions for webpack
// Project: https://github.com/webpack/webpack
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "webpack" {
namespace webpack {
interface Configuration {
module?: Module;
plugins?: Plugin[];
}
interface Module {
loaders?: Loader[];
}
interface Loader {
test: RegExp;
loader?: string;
loaders?: string[];
query?: {
[name: string]: any;
}
}
interface Plugin {
}
interface ResolverPlugin extends Plugin {
}
interface ResolverPluginStatic {
new(plugins: Plugin[], files: string[]): ResolverPlugin;
DirectoryDescriptionFilePlugin: DirectoryDescriptionFilePluginStatic;
}
interface DirectoryDescriptionFilePlugin extends Plugin {
}
interface DirectoryDescriptionFilePluginStatic {
new(file: string, files: string[]): DirectoryDescriptionFilePlugin;
}
interface Webpack {
ResolverPlugin: ResolverPluginStatic;
}
}
var webpack: webpack.Webpack;
export default webpack;
}