vue 配置发布测试环境,成产环境api
vue通过配置不同命令自动发布到测试环境或者成产环境
cnpm run build 配置开发环境
cnpm run build:test 打包到测试环境
cnpm run build:prod 打包到成产环境
vue 在vue-cli脚手架会生成build config两个文件夹
在build文件夹下新建webpack.test.conf.js 将webpack.prod.conf.js内容复制过来
将webpack.test.conf.js 修改成 const env = require(‘../config/test.env‘)
const env = require(‘../config/test.env‘)
在config新建test.env.js 将prod.env.js复制过来
test.env.js
‘use strict‘ module.exports = { NODE_ENV: ‘"production"‘, API_ROOT:‘"http://测试.com:18081/app/"‘ }
prod.env.js
‘use strict‘ module.exports = { NODE_ENV: ‘"production"‘, API_ROOT:‘"https://正式.com/app/"‘ }
dev.env.js
‘use strict‘ const merge = require(‘webpack-merge‘) const prodEnv = require(‘./prod.env‘) module.exports = merge(prodEnv, { NODE_ENV: ‘"development"‘, API_ROOT: ‘/api/‘ })
在build下新建test.js
将build.js内容复制到test.js
const webpackConfig = require(‘./webpack.test.conf‘)
最后修改package.json
"scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "e2e": "node test/e2e/runner.js", "test": "npm run e2e", "build": "node build/build.js", "build:test":"node build/test.js" },
相关推荐
justlike 2020-09-02
Henryztong 2020-06-25
deadgrape 2020-06-09
abdstime 2020-06-03
jszy 2020-05-25
zzjmay 2020-05-17
Henryztong 2020-03-07
RocketJ 2020-02-22
chichichi0 2020-02-09
woxxoole 2020-02-02
Henryztong 2020-01-30
woxxoole 2019-12-30
deyu 2019-12-18
abdstime 2019-12-10
Christsam 2019-11-19
thug 2019-11-17
hulao 2019-11-12