2020-06-10分环境打包方案

2020-06-10  本文已影响0人  0说

目录

在这个目录下建文件webpack会自动加载


image.png

.env.development

#本地运行环境
NODE_ENV='development' //定义标识环境
VUE_APP_URL='http://192.168.2.218:7999'
VUE_APP_IMGURL='http://192.168.2.218:7999/document'

.env.development

NODE_ENV='production' //定义标识环境
VUE_APP_URL='http://192.168.2.218:7999'
VUE_APP_IMGURL='http://192.168.2.218:7999/document'

.env.test

NODE_ENV='production'
VUE_APP_URL='http://smart.yunmansk.com'
VUE_APP_IMGURL='http://smart.yunmansk.com/document'

在package.json文件把命令写进去

"scripts": {
    "dev": "vue-cli-service serve --open",
    "build": "vue-cli-service build",
    "build-dev": "vue-cli-service build --mode dev",
    "build-test": "vue-cli-service build --mode test",
    "build-master": "vue-cli-service build --mode master",
    "build-prop": "vue-cli-service build --mode prop",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit",
    "test:e2e": "vue-cli-service test:e2e"
  },

对应的文件把环境变量赋值



运行:

npm run test
npm run build-test
上一篇 下一篇

猜你喜欢

热点阅读