diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts new file mode 100644 index 000000000..bd3de95a2 --- /dev/null +++ b/webpack/webpack-tests.ts @@ -0,0 +1,47 @@ +/// + +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"]) + ] +}; + diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts new file mode 100644 index 000000000..c8381e7e4 --- /dev/null +++ b/webpack/webpack.d.ts @@ -0,0 +1,53 @@ +// Type definitions for webpack +// Project: https://github.com/webpack/webpack +// Definitions by: Qubo +// 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; +} +