javascript - Vue staging build 创建一个开发构建而不是生产

标签 javascript vue.js

Vue documentation :

vue-cli-service build --mode staging builds a production app in staging mode, using .env, .env.staging and .env.staging.local if they are present.

包.json

"buildStaging": "vue-cli-service build --mode staging",

.env.staging

VUE_APP_LOG_PRODUCTION_TIP=true

然后

>npm run buildStaging
> between-us-drivers@0.1.0 buildStaging C:\dev\mezinamiridici\spa
> vue-cli-service build --mode staging
/  Building for staging...

结果是:

171 650 admin-chunk.js
112 650 admin-chunk.js.map
6 156 774 app.js
6 008 903 app.js.map
1 517 776 content-chunk.js
1 434 561 content-chunk.js.map
477 276 user-chunk.js
425 751 user-chunk.js.map

为什么有开发构建而不是生产构建?

最佳答案

如果您希望您的暂存生成生产版本,您需要通过 .env.staging 中的 NODE_ENV 指定它:

NODE_ENV=production
VUE_APP_LOG_PRODUCTION_TIP=true

这在 the documentation example for staging 中有所暗示,但未突出显示:

The app is built as a production app because of the NODE_ENV, but in the staging version, process.env.VUE_APP_TITLE is overwritten with a different value

核心行为在 the documentation 中稍早介绍了:

When running vue-cli-service, [...] NODE_ENV will be set to "production" in production mode, "test" in test mode, and defaults to "development" otherwise.

关于javascript - Vue staging build 创建一个开发构建而不是生产,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64881963/

相关文章:

javascript - 将 Prop 传递到模板中

javascript - 如何从xml文件中删除节点?

javascript - 如何将oEmbed对象中的html直接写入jade模板中?

vue.js - VueJS : TypeError: Cannot read property of undefined when Reload

javascript - 为 VueJS 组件嵌入 Java 脚本映射

typescript - 如何在没有类样式或装饰器语法的情况下获取 mapGetters、mapActions Vuex 和 typescript 的智能感知

vue.js - 迁移 "slot"已弃用的语法

javascript - 如何在 nodejs 12 中使用私有(private)类字段?

javascript - nodeJs soap 库无法将请求发送到 wsdl url

javascript - 如何将每个数组元素添加到N数组中?