天天看點

vue 打包 根據指令的不同 打包不同的環境

第一步 複制prod.env.js 為prod.test.js

'use strict'
module.exports = {
  NODE_ENV: '"testing"',
  is_weixin: ' "1" '
}
           

第二部 修改webpack.prod.conf.js檔案的判斷

vue 打包 根據指令的不同 打包不同的環境
const env = process.env.npm_lifecycle_script.split("--")[1] === 'testing'
  ? require('../config/test.env')
  : require('../config/prod.env')
           

第三步 在打包的時候加上

vue 打包 根據指令的不同 打包不同的環境
"test": "node build/build.js --testing",
           

運作 npm run test