网页
综合
更新时间 2026-11-14 09:17:26
Environment Variables | webpack
自动蜘蛛
webpack.js.org
正文约 1602 字
To disambiguate in your webpack.config.js between development and production builds you may use environment variables.
webpack's environment variables are different from the environment variables of operating system shells like bash and CMD.exe
The webpack command line environment option --env allows you to pass in as many environment variables as you like. Environment variables will be made accessible in your webpack.config.js. For example, --env production or --env goal=local.
Setting up your env variable without assignment, --env production sets env.production to true by default. There are also other syntaxes that you can use. See the webpack CLI documentation for more information.
There is one change that you will have to make to your webpack config. Typically, export default points to the configuration object. To use the env variable, you must make export default a function:
Webpack CLI offers some built-in environment variables which you can access inside a webpack configuration.
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搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。