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.
Because it's a standard Node.js CommonJS module, you can do the following:
require(...)
require(...)
?:
operatorUse these features when appropriate.
While they are technically feasible, the following practices should be avoided:
--env
)The examples below describe how webpack's configuration can be both expressive and configurable because it is code:
webpack.config.js
const path = require('path'); module.exports = { mode: 'development', entry: './foo.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'foo.bundle.js', }, };
See: Configuration section for all supported configuration options
Along with exporting a single configuration as an object, function or Promise, you can export multiple configurations.
See: Exporting multiple configurations
Webpack accepts configuration files written in multiple programming and data languages.
© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/concepts/configuration