Sponsor webpack and get apparel from the official shop or get stickers here! All proceeds go to our open collective!

ag-grid is proud to partner with webpack

Mode

Providing the mode configuration option tells webpack to use its built-in optimizations accordingly.

string

Usage

Just provide the mode option in the config:

module.exports = {
  mode: 'production'
};

or pass it as a CLI argument:

webpack --mode=production

If not set, webpack sets production as the default value for mode. The supported values for mode are:

Option
Description
Option
development
Description
Provides process.env.NODE_ENV with value development. Enables NamedChunksPlugin and NamedModulesPlugin.
Option
production
Description
Provides process.env.NODE_ENV with value production. Enables FlagDependencyUsagePlugin, FlagIncludedChunksPlugin, ModuleConcatenationPlugin, NoEmitOnErrorsPlugin, OccurrenceOrderPlugin, SideEffectsFlagPlugin and UglifyJsPlugin.
Option
none
Description
Opts out of any default optimization options
Please remember that setting NODE_ENV doesn't automatically set mode.

Mode: development

// webpack.development.config.js
module.exports = {
+ mode: 'development'
- plugins: [
-   new webpack.NamedModulesPlugin(),
-   new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("development") }),
- ]
}

Mode: production

// webpack.production.config.js
module.exports = {
+  mode: 'production',
-  plugins: [
-    new UglifyJsPlugin(/* ... */),
-    new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }),
-    new webpack.optimize.ModuleConcatenationPlugin(),
-    new webpack.NoEmitOnErrorsPlugin()
-  ]
}

Mode: none

// webpack.custom.config.js
module.exports = {
+  mode: 'none',
-  plugins: [
-  ]
}

Contributors