webpack环境配置
1.首先安装 cross-env
npm install cross-env --save-dev
在package.json里面配置 根据不同命令打包
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack.config.dev.js",
"dev:test": "cross-env NODE_ENV=test webpack-dev-server --config webpack.config.dev.js",
"dev:prod": "cross-env NODE_ENV=production webpack-dev-server --config webpack.config.dev.js",
"build:dev": "cross-env NODE_ENV=development webpack --config webpack.config.dev.js",
"build:test": "cross-env NODE_ENV=test webpack --config webpack.config.dev.js",
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"build": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
3.在封装的axios配置同意前缀变量
axios.defaults.baseURL = process.env.API_BASE_URL
THE END
webpack环境配置
1.首先安装 cross-env
npm install cross-env --save-dev
在package.json里面配置 根据不同命令打包
"scripts": {
"dev": "cross-env NODE_ENV=develo……
爱上辉煌台