在项目根目录新建三个env文件
.env.development //开发环境
.env.production //生产环境
.env.test //测试环境
.env.development
NODE_ENV = 'development'
VUE_APP_MODE = 'development'
VUE_APP_BASE_URL = "http://testapi"
.env.production
NODE_ENV = 'production'
VUE_APP_MODE = 'production'
VUE_APP_BASE_URL = 'http://api'
.env.test
NODE_ENV = 'production'
VUE_APP_MODE = 'test'
VUE_APP_BASE_URL = "http://testapi"
outputDir = test
配置完成重新npm run serve启动
打印process.env看到自己的配置项
vue.config文件 没有就新建一个
module.exports = {
publicPath: "./",
lintOnSave: false, //关闭eslint
outputDir: process.env.outputDir,
};
更改package.json文件
"build": "vue-cli-service build && vue-cli-service build --mode test",
"test": "vue-cli-service build --mode test",
npm run test会生成test文件夹
npm run build 会同时打包两个文件夹dist和test
dist文件夹放在生产环境
test文件夹放在测试环境
本文地址:https://blog.csdn.net/AK852369/article/details/107121649
如对本文有疑问, 点击进行留言回复!!
vue axios跨域问题Access-Control-Allow-Origin‘ header is present on the requested resourc解决方案
在写vue项目时.vue后缀名的页面中写注释双斜杆报错的解决方法
网友评论