In this webpack starter kit https://github.com/webpack/react-starter I see the webpack.production.config.js module does not export only a config object but an array of config objects instead:
module.exports = [
require("./make-webpack-config")({
// commonsChunk: true,
longTermCaching: true,
separateStylesheet: true,
minimize: true
// devtool: "source-map"
}),
require("./make-webpack-config")({
prerender: true
})
];
What will happen in this case, when multiple config objects are provided? It isn't mentioned in webpack's docs
Webpack configs allow you to configure and extend Webpack's basic functionality. A Webpack config is a JavaScript object that configures one of Webpack's options. Most projects define their Webpack config in a top-level webpack. config. js file, although you can also pass the config as a parameter to Webpack's Node.
The easiest way to get your webpack. config. js file to work is to place it at the top level of your project's folder structure along with your package. json file.
You may have noticed that few webpack configurations look exactly alike. This is because webpack's configuration file is a JavaScript file that exports a webpack configuration. This configuration is then processed by webpack based upon its defined properties.
Out of the box, webpack won't require you to use a configuration file. However, it will assume the entry point of your project is src/index. js and will output the result in dist/main.
Passing an array enables Webpack's multi-compiler mode. It's just a way to run Webpack multiple times in one pass. For instance, if you're making a Chrome & Firefox extension, you could use the multi-compiler to create both at once.
Webpack Multi-compiler example using mobile/desktop bundles.
Can be used to produce two different outputs - otherwise undoable in Webpack (AFAIK).
Eg: Produce full Production-ready output config into wwwroot directory in an ASP.Net Server-side web app, so that you can run and test everything by running the ASP.Net app on IIS, in Visual Studio WHILE SIMULTANEOUSLY Produce a simple HTML page (with HtmlWebpackPlugin) into your_app/dist folder, so you can run just the JS app and on Webpack DevServer and edit the JS app, in VSCode
Two people could work side by side on the same project, at the same time, the way John Lennon Imagined...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With