1、用@vue/cli脚手架搭建的项目初始化后应该是这样的:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
2、配置后:
"scripts": {
"serve": "vue-cli-service serve --mode development",
"build": "vue-cli-service build --mode production",
"build:test": "vue-cli-service build --mode testing",
},
3、在根目录下(与package.json同级目录)创建三个文件来标识三个环境对应的变量:
.env.development、.env.production、.env.testing
在文件中可以写上对应环境的变量值,默认有一个NODE_ENV变量,值为环境名:development、production、testing