Movatterモバイル変換


[0]ホーム

URL:


webpack logo
ag grid
ag charts

Mode

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

string = 'production': 'none' | 'development' | 'production'

Usage

Provide themode option in the config:

module.exports={  mode:'development',};

or pass it as aCLI argument:

webpack --mode=development

The following string values are supported:

OptionDescription
developmentSetsprocess.env.NODE_ENV onDefinePlugin to valuedevelopment. Enables useful names for modules and chunks.
productionSetsprocess.env.NODE_ENV onDefinePlugin to valueproduction. Enables deterministic mangled names for modules and chunks,FlagDependencyUsagePlugin,FlagIncludedChunksPlugin,ModuleConcatenationPlugin,NoEmitOnErrorsPlugin andTerserPlugin.
noneOpts out of any default optimization options

If not set, webpack setsproduction as the default value formode.

tip

Ifmode is not provided via configuration or CLI, CLI will use any validNODE_ENV value formode.

Mode: development

// webpack.development.config.jsmodule.exports={  mode:'development',};

Mode: production

// webpack.production.config.jsmodule.exports={  mode:'production',};

Mode: none

// webpack.custom.config.jsmodule.exports={  mode:'none',};

If you want to change the behavior according to themode variable inside thewebpack.config.js, you have to export a function instead of an object:

var config={  entry:'./app.js',//...};module.exports=(env, argv)=>{if(argv.mode==='development'){    config.devtool='source-map';}if(argv.mode==='production'){//...}return config;};
Next »
Output

6 Contributors

EugeneHlushkobyzykmrichmondFentalsnitin315chenxsan

[8]ページ先頭

©2009-2025 Movatter.jp