[英]Webpack environment variable NODE_ENV vs cli params --env
what's the difference between set environment variable and cli environment options? 设置环境变量和cli环境选项之间有什么区别?
for example 例如
cross-env NODE_ENV=production webpack
then 然后
const isProd = process.env.NODE_ENV === 'production'
or 要么
webpack --env.production
then 然后
module.exports = function (env) {
....
}
which is better? 哪个更好?
webpack --env.production is prob better since it will ensure that all variables that should be set are set. webpack --env.production可能会更好,因为它将确保设置所有应设置的变量。 Admittedly, it is probably only setting NODE_ENV=production - however, in the future things might change and this approach will ensure you are always taking the best current approach.
诚然,它可能仅设置NODE_ENV = production-但是,将来情况可能会发生变化,并且这种方法将确保您始终采用最佳的当前方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.