网页
综合
更新时间 2026-11-14 16:19:15
Extends | webpack
自动蜘蛛
webpack.js.org
正文约 2091 字
The extends property allows you to extend an existing configuration to use as the base. It internally uses the webpack-merge package to merge the configurations and helps you to avoid duplicating configurations between multiple configurations.
This option is not supported via the Node API: Extends will have no effect when using the Node API. webpack-cli is required to use this feature.
base.webpack.config.js
You can extend multiple configurations at once by passing an array of configuration paths to the extends property.
Configurations from the extends property are merged from right to left, meaning that the configuration on the right will be merged into the configuration on the left. Configuration can be overridden by passing the same property in the configuration on the right.
js.webpack.config.js
css.webpack.config.js
You can override configurations from the extended configuration by passing the same property in the configuration that extends it.
base.webpack.config.js
While primitive values (such as strings) are overridden, array fields are concatenated instead of replaced. This behavior comes from webpack-merge, which Webpack uses internally when processing extends.
base.webpack.config.js
Result after merging
Instead of module being replaced the rules and plugins array got concatenated
You can also load configuration from third-party packages by passing the package name to the extends property. The package must export the webpack configuration in package.json.
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
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。