vue项目打包后报错Cannot read property 'NODE_ENV' of undefined

我的环境

webpack 3.6.0  vue 2.3.3   ---版本很重要(如果你跟我的版本相差太大可能要另寻解决办法)

webpack.prod.conf.js中需要配置DefinePlugin如下---完美解决

var webpack = require('webpack')

module.exports = {
  // ...
  plugins: [
    // ...
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production')
    })
  ]
}

官方文档:https://vuejs.org/v2/guide/deployment.html#Without-Build-Tools

你可能感兴趣的:(vue)