[英]Multiple .env.development configs in Vue/Webpack
I feel this should not be a hard thing to do, but I can't get it to run.我觉得这不应该是一件很难的事情,但我无法让它运行。
I want to have two different configs for my local Vue.js project (using vue-cli 3).我想为我的本地 Vue.js 项目使用两个不同的配置(使用 vue-cli 3)。
So, I want to have .env.development-1
and .env-development-2
or something like that;所以,我想要
.env.development-1
和.env-development-2
或类似的东西; just a way to quickly switch between two otherwise identical configuration files.只是一种在两个完全相同的配置文件之间快速切换的方法。
I've read about build modes etc, but those articles all seem to target "building".我读过有关构建模式等的内容,但这些文章似乎都针对“构建”。 I just want to run local devserver with a different config.
我只想用不同的配置运行本地开发服务器。
How would I solve this?我将如何解决这个问题?
Thanks to the comments under my original post, i found out that the solution is, in fact, really easy:感谢我原帖下的评论,我发现解决方案实际上非常简单:
i just made an .env.staging
with the VUE_APP_API_URL
pointing to the staging server, everything else being the same我刚刚做了一个
.env.staging
,其中VUE_APP_API_URL
指向登台服务器,其他一切都一样
then然后
"scripts": {
"serve:local": "vue-cli-service serve",
"serve:staging": "vue-cli-service serve --mode staging",
}
and it works.它有效。
first had to wrap my head around the concept.首先必须把我的脑袋围绕在这个概念上。 thanks!
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.