import webpack = require('webpack'); import { RawSourceMap } from 'source-map'; const { optimize, } = webpack; let plugins: webpack.Plugin[]; /** * Plugins */ /** * optimize */ const { AggressiveMergingPlugin, } = optimize; plugins = [ new AggressiveMergingPlugin(), new AggressiveMergingPlugin({}), new AggressiveMergingPlugin({ entryChunkMultiplicator: 10, minSizeReduce: 1.5, moveToParents: false, }), ]; let configuration: webpack.Configuration; let rule: webpack.Rule; let plugin: webpack.Plugin; declare const __dirname: string; // // 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"] }, ] } }; rule = { test: /\.png$/, loader: "url-loader?mimetype=image/png" }; rule = { test: /\.png$/, loader: "url-loader", query: { mimetype: "image/png" } }; // // http://webpack.github.io/docs/tutorials/getting-started/ // configuration = { entry: "./entry.js", output: { path: __dirname, filename: "bundle.js" }, module: { loaders: [ { test: /\.css$/, loader: "style!css" } ] } }; // // https://webpack.js.org/configuration/entry-context/#dynamic-entry // configuration = { entry: () => './demo' }; configuration = { entry: () => ['./demo', './demo2'] }; configuration = { entry: () => new Promise((resolve) => resolve('./demo')) }; configuration = { entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) }; // // https://webpack.github.io/docs/code-splitting.html // configuration = { entry: { app: "./app.js", vendor: ["jquery", "underscore"], }, output: { filename: "bundle.js" }, plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: "vendor", filename: "vendor.bundle.js", }), ] }; configuration = { entry: { a: "./a", b: "./b" }, output: { filename: "[name].js" }, plugins: [new webpack.optimize.CommonsChunkPlugin({ name: "init.js" })] }; // // https://webpack.github.io/docs/stylesheets.html // configuration = { // ... module: { loaders: [ { test: /\.css$/, loader: "style-loader!css-loader" } ] } }; // // https://webpack.github.io/docs/optimization.html // configuration = { entry: { p1: "./page1", p2: "./page2", p3: "./page3" }, output: { filename: "[name].entry.chunk.js" } }; const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin; configuration = { entry: { p1: "./page1", p2: "./page2", p3: "./page3" }, output: { filename: "[name].entry.chunk.js" }, plugins: [ new CommonsChunkPlugin({ name: "commons.chunk.js" }) ] }; configuration = { entry: { p1: "./page1", p2: "./page2", p3: "./page3", ap1: "./admin/page1", ap2: "./admin/page2" }, output: { filename: "[name].js" }, }; //