webpack.config.js (1472B)
1 const path = require("path"); 2 const webpack = require("webpack"); 3 4 const config = { 5 devtool: "sourcemap", 6 }; 7 8 if (webpack.version && webpack.version[0] === "4") { 9 // Webpack 3, used in sourcemaps-reload-uncompressed, doesn't support mode attribute. 10 // Webpack 4, used in sourcemaps-reload-compressed we want production mode in order to compress the sources 11 config.mode = "production"; 12 } else { 13 // Also Webpack 4 doesn't support the module.loaders attribute 14 config.module = { 15 loaders: [ 16 { 17 test: /\.js$/, 18 exclude: /node_modules/, 19 loader: "babel-loader", 20 }, 21 ], 22 }; 23 } 24 25 const originalBundle = Object.assign({}, config, { 26 entry: [path.join(__dirname, "original.js")], 27 output: { 28 path: __dirname, 29 filename: "bundle.js", 30 }, 31 }); 32 33 const bundleWithAnotherOriginalFile = Object.assign({}, config, { 34 entry: [ 35 // This should cause the content of `original-with-no-update.js` 36 // to shift in the new `bundle-with-another-original.js` generated. 37 path.join(__dirname, "another-original.js"), 38 path.join(__dirname, "original-with-no-update.js") 39 ], 40 output: { 41 path: __dirname, 42 filename: "bundle-with-another-original.js" 43 } 44 }); 45 46 const replacedBundle = Object.assign({}, config, { 47 entry: [path.join(__dirname, "new-original.js")], 48 output: { 49 path: __dirname, 50 filename: "replaced-bundle.js", 51 }, 52 }); 53 54 module.exports = [originalBundle, bundleWithAnotherOriginalFile, replacedBundle];