diff --git a/examples/aggressive-merging/webpack.config.js b/examples/aggressive-merging/webpack.config.js index 9b651f2f7..739102bb7 100644 --- a/examples/aggressive-merging/webpack.config.js +++ b/examples/aggressive-merging/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin"); module.exports = { + mode: "production", entry: { pageA: "./pageA", pageB: "./pageB", diff --git a/examples/build-common.js b/examples/build-common.js index 24b61463f..a7be20941 100644 --- a/examples/build-common.js +++ b/examples/build-common.js @@ -11,9 +11,11 @@ const fs = require("fs"); const extraArgs = ""; -const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js"; +const hasConfiguration = fs.existsSync("webpack.config.js"); +const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js "; const displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used-exports --display-provided-exports"; -cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) { +const modeArgs = hasConfiguration ? "" : "--mode production"; +cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) { if(stderr) console.log(stderr); if(error !== null) @@ -25,7 +27,7 @@ cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} console.log(stderr); throw e; } - cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) { + cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${modeArgs} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) { console.log(stdout); if(stderr) console.log(stderr); diff --git a/examples/chunkhash/webpack.config.js b/examples/chunkhash/webpack.config.js index 817f492b3..27afca015 100644 --- a/examples/chunkhash/webpack.config.js +++ b/examples/chunkhash/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", entry: { main: "./example", common: ["./vendor"] // optional diff --git a/examples/code-splitted-css-bundle/webpack.config.js b/examples/code-splitted-css-bundle/webpack.config.js index d443e0a2f..c182c3d51 100644 --- a/examples/code-splitted-css-bundle/webpack.config.js +++ b/examples/code-splitted-css-bundle/webpack.config.js @@ -1,6 +1,7 @@ const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", module: { rules: [ { diff --git a/examples/coffee-script/webpack.config.js b/examples/coffee-script/webpack.config.js index 8bd41bcf4..bdb91adf8 100644 --- a/examples/coffee-script/webpack.config.js +++ b/examples/coffee-script/webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + mode: "production", module: { rules: [ { test: /\.coffee$/, loader: "coffee-loader" } diff --git a/examples/common-chunk-and-vendor-chunk/webpack.config.js b/examples/common-chunk-and-vendor-chunk/webpack.config.js index a85c3e4eb..42f93af81 100644 --- a/examples/common-chunk-and-vendor-chunk/webpack.config.js +++ b/examples/common-chunk-and-vendor-chunk/webpack.config.js @@ -2,6 +2,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { vendor: ["./vendor1", "./vendor2"], pageA: "./pageA", diff --git a/examples/common-chunk-grandchildren/webpack.config.js b/examples/common-chunk-grandchildren/webpack.config.js index 7b2696d7b..047035e32 100644 --- a/examples/common-chunk-grandchildren/webpack.config.js +++ b/examples/common-chunk-grandchildren/webpack.config.js @@ -4,6 +4,7 @@ const path = require("path"); module.exports = [ { + mode: "production", entry: { main: ["./example.js"] }, @@ -21,6 +22,7 @@ module.exports = [ ] }, { + mode: "production", entry: { main: ["./example.js"] }, diff --git a/examples/css-bundle/webpack.config.js b/examples/css-bundle/webpack.config.js index ed5279ebd..530248cd0 100644 --- a/examples/css-bundle/webpack.config.js +++ b/examples/css-bundle/webpack.config.js @@ -1,6 +1,7 @@ const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", module: { rules: [ { diff --git a/examples/dll-app-and-vendor/0-vendor/webpack.config.js b/examples/dll-app-and-vendor/0-vendor/webpack.config.js index 89b48fa5e..8477db863 100644 --- a/examples/dll-app-and-vendor/0-vendor/webpack.config.js +++ b/examples/dll-app-and-vendor/0-vendor/webpack.config.js @@ -2,6 +2,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { + mode: "production", context: __dirname, entry: ["example-vendor"], output: { diff --git a/examples/dll-app-and-vendor/1-app/webpack.config.js b/examples/dll-app-and-vendor/1-app/webpack.config.js index 2a02109d0..02ff7b1f3 100644 --- a/examples/dll-app-and-vendor/1-app/webpack.config.js +++ b/examples/dll-app-and-vendor/1-app/webpack.config.js @@ -2,6 +2,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { + mode: "production", context: __dirname, entry: "./example-app", output: { diff --git a/examples/dll-user/webpack.config.js b/examples/dll-user/webpack.config.js index 45aed8fd9..a7ecc9527 100644 --- a/examples/dll-user/webpack.config.js +++ b/examples/dll-user/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", plugins: [ new webpack.DllReferencePlugin({ context: path.join(__dirname, "..", "dll"), diff --git a/examples/dll/webpack.config.js b/examples/dll/webpack.config.js index e907576bd..12bfab15a 100644 --- a/examples/dll/webpack.config.js +++ b/examples/dll/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", resolve: { extensions: [".js", ".jsx"] }, diff --git a/examples/explicit-vendor-chunk/webpack.config.js b/examples/explicit-vendor-chunk/webpack.config.js index cf61f7439..43d54b4b9 100644 --- a/examples/explicit-vendor-chunk/webpack.config.js +++ b/examples/explicit-vendor-chunk/webpack.config.js @@ -3,6 +3,7 @@ var webpack = require("../../"); module.exports = [ { name: "vendor", + mode: "production", entry: ["./vendor", "./vendor2"], output: { path: path.resolve(__dirname, "js"), @@ -18,6 +19,7 @@ module.exports = [ }, { name: "app", + mode: "production", dependencies: ["vendor"], entry: { pageA: "./pageA", diff --git a/examples/externals/webpack.config.js b/examples/externals/webpack.config.js index fa5cddbc4..b3c40b98b 100644 --- a/examples/externals/webpack.config.js +++ b/examples/externals/webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + mode: "production", output: { libraryTarget: "umd" }, diff --git a/examples/extra-async-chunk-advanced/webpack.config.js b/examples/extra-async-chunk-advanced/webpack.config.js index 33a80ed0d..0e03a70f9 100644 --- a/examples/extra-async-chunk-advanced/webpack.config.js +++ b/examples/extra-async-chunk-advanced/webpack.config.js @@ -1,6 +1,7 @@ var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", plugins: [ new CommonsChunkPlugin({ name: "main", diff --git a/examples/extra-async-chunk/webpack.config.js b/examples/extra-async-chunk/webpack.config.js index f0331d1c0..413b70aa2 100644 --- a/examples/extra-async-chunk/webpack.config.js +++ b/examples/extra-async-chunk/webpack.config.js @@ -1,6 +1,7 @@ var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", plugins: [ new CommonsChunkPlugin({ // process all children of the main chunk diff --git a/examples/harmony-library/webpack.config.js b/examples/harmony-library/webpack.config.js index 50ef8f0b7..699800918 100644 --- a/examples/harmony-library/webpack.config.js +++ b/examples/harmony-library/webpack.config.js @@ -1,5 +1,6 @@ var path = require("path"); module.exports = { + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), diff --git a/examples/harmony-unused/webpack.config.js b/examples/harmony-unused/webpack.config.js new file mode 100644 index 000000000..4a357a8d0 --- /dev/null +++ b/examples/harmony-unused/webpack.config.js @@ -0,0 +1,6 @@ +module.exports = { + mode: "production", + optimization: { + concatenateModules: false + } +}; diff --git a/examples/http2-aggressive-splitting/webpack.config.js b/examples/http2-aggressive-splitting/webpack.config.js index e875b026f..cd0476ffd 100644 --- a/examples/http2-aggressive-splitting/webpack.config.js +++ b/examples/http2-aggressive-splitting/webpack.config.js @@ -1,6 +1,8 @@ var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", + cache: true, // better performance for the AggressiveSplittingPlugin entry: "./example", output: { path: path.join(__dirname, "js"), diff --git a/examples/hybrid-routing/webpack.config.js b/examples/hybrid-routing/webpack.config.js index e9a3b08ce..1fe4e1d6d 100644 --- a/examples/hybrid-routing/webpack.config.js +++ b/examples/hybrid-routing/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { // The entry points for the pages pageA: "./aEntry", diff --git a/examples/i18n/webpack.config.js b/examples/i18n/webpack.config.js index 30d446215..321c77f7d 100644 --- a/examples/i18n/webpack.config.js +++ b/examples/i18n/webpack.config.js @@ -7,6 +7,7 @@ var languages = { module.exports = Object.keys(languages).map(function(language) { return { name: language, + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), diff --git a/examples/loader/webpack.config.js b/examples/loader/webpack.config.js index 854df7f70..54fd5a1d5 100644 --- a/examples/loader/webpack.config.js +++ b/examples/loader/webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + mode: "production", module: { rules: [ { test: /\.css$/, loader: "css-loader" } diff --git a/examples/move-to-parent/webpack.config.js b/examples/move-to-parent/webpack.config.js index f39633eae..c8cf055b6 100644 --- a/examples/move-to-parent/webpack.config.js +++ b/examples/move-to-parent/webpack.config.js @@ -7,12 +7,14 @@ var outputOptions = { }; module.exports = [{ name: "page", + mode: "production", entry: { page: "./page" }, output: outputOptions }, { name: "pageA", + mode: "production", entry: { pageA: "./page" }, @@ -26,6 +28,7 @@ module.exports = [{ ] }, { name: "pageB", + mode: "production", entry: { pageB: "./page" }, @@ -40,6 +43,7 @@ module.exports = [{ ] }, { name: "pageC", + mode: "production", entry: { pageC: "./page" }, diff --git a/examples/multi-compiler/webpack.config.js b/examples/multi-compiler/webpack.config.js index b6f932f29..ef27f86df 100644 --- a/examples/multi-compiler/webpack.config.js +++ b/examples/multi-compiler/webpack.config.js @@ -3,6 +3,7 @@ var webpack = require("../../"); module.exports = [ { name: "mobile", + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), @@ -16,6 +17,7 @@ module.exports = [ }, { name: "desktop", + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), diff --git a/examples/multi-part-library/webpack.config.js b/examples/multi-part-library/webpack.config.js index a747606bc..d7681599d 100644 --- a/examples/multi-part-library/webpack.config.js +++ b/examples/multi-part-library/webpack.config.js @@ -1,5 +1,6 @@ var path = require("path"); module.exports = { + mode: "production", entry: { alpha: "./alpha", beta: "./beta" diff --git a/examples/multiple-commons-chunks/webpack.config.js b/examples/multiple-commons-chunks/webpack.config.js index e1a66ea31..5c08e5c47 100644 --- a/examples/multiple-commons-chunks/webpack.config.js +++ b/examples/multiple-commons-chunks/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { pageA: "./pageA", pageB: "./pageB", diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js index 270426855..357232683 100644 --- a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js +++ b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js @@ -3,6 +3,7 @@ const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", entry: { A: "./a", B: "./b", diff --git a/examples/multiple-entry-points/webpack.config.js b/examples/multiple-entry-points/webpack.config.js index 015615814..67cdddef3 100644 --- a/examples/multiple-entry-points/webpack.config.js +++ b/examples/multiple-entry-points/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { pageA: "./pageA", pageB: "./pageB" diff --git a/examples/scope-hoisting/webpack.config.js b/examples/scope-hoisting/webpack.config.js index da883a7c1..b913c78ab 100644 --- a/examples/scope-hoisting/webpack.config.js +++ b/examples/scope-hoisting/webpack.config.js @@ -1,7 +1,3 @@ -var webpack = require("../../"); - module.exports = { - plugins: [ - new webpack.optimize.ModuleConcatenationPlugin() - ] + mode: "production" }; diff --git a/examples/source-map/webpack.config.js b/examples/source-map/webpack.config.js index 7f0dac899..0b73dfbef 100644 --- a/examples/source-map/webpack.config.js +++ b/examples/source-map/webpack.config.js @@ -13,6 +13,7 @@ module.exports = [ "nosources-source-map", "source-map", ].map(devtool => ({ + mode: "development", entry: { bundle: "coffee-loader!./example.coffee", }, diff --git a/examples/two-explicit-vendor-chunks/webpack.config.js b/examples/two-explicit-vendor-chunks/webpack.config.js index 3d7b5f8ad..d2c29bf69 100644 --- a/examples/two-explicit-vendor-chunks/webpack.config.js +++ b/examples/two-explicit-vendor-chunks/webpack.config.js @@ -1,6 +1,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { vendor1: ["./vendor1"], vendor2: ["./vendor2"], diff --git a/examples/wasm-simple/webpack.config.js b/examples/wasm-simple/webpack.config.js index d2df12225..2a8a66b19 100644 --- a/examples/wasm-simple/webpack.config.js +++ b/examples/wasm-simple/webpack.config.js @@ -1,4 +1,5 @@ module.exports = { + mode: "production", output: { webassemblyModuleFilename: "[modulehash].wasm", publicPath: "js/" diff --git a/examples/web-worker/webpack.config.js b/examples/web-worker/webpack.config.js index 279ff0689..1d90a6229 100644 --- a/examples/web-worker/webpack.config.js +++ b/examples/web-worker/webpack.config.js @@ -1,5 +1,6 @@ var webpack = require("../../"); module.exports = { + mode: "production", plugins: [ new webpack.LoaderOptionsPlugin({ options: {