1.在根路径下创建.env文件

2.写.env文件内容
文件里存储的值的key要以 VUE_APP 开头
VUE_APP

VUE_APP_PUBLIC_PATH='/'

VUE_APP_PUBLIC_PATH='/helper/'
3.使用

publicPath: process.env.VUE_APP_PUBLIC_PATH,
4.配置package.json
"serve:production": "vue-cli-service serve --mode production",
"build:production": "vue-cli-service build --mode production",

5.使用环境变量打包
npm run build:production