网页 综合 更新时间 2026-11-14 05:11:45

Mode | webpack

自动蜘蛛 webpack.js.org 正文约 2058 字
Mode | webpack
Providing the mode configuration option tells webpack to use its built-in optimizations accordingly.
'none' | 'development' | 'production' = 'production'
Provide the mode option in the config:
or pass it as a CLI argument:
The following string values are supported:
If not set, webpack sets production as the default value for mode.
If mode is not provided via configuration or CLI, CLI will use any valid NODE_ENV value for mode.
mode doesn't do anything by itself — it picks the defaults of other options, each of which you can still set explicitly. These are the options whose default depends on it:
optimization.splitChunks is also tuned by mode: minSize, enforceSizeThreshold, maxAsyncRequests and maxInitialRequests are stricter in production. See SplitChunksPlugin for their values.
Two rows come with a condition: performance.hints only applies to browser targets, and devtool stays false in development when the build outputs an ES module library. With experiments.css enabled, development additionally defaults CSS assets to source-map.
mode: 'none' only opts out of the defaults listed here. Options that don't depend on the mode — such as optimization.providedExports or optimization.removeEmptyChunks — keep their usual defaults, and mode: 'none' is not the same as disabling every optimization.
If you want to change the behavior according to the mode variable inside the webpack.config.js, you have to export a function instead of an object:
Copyright OpenJS Foundation and webpack contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy
访问原文 返回搜索 https://webpack.js.org/configuration/mode/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。