关于vue2中使用elementUi打包报错修正

bug1.找不到element-ui/lib/theme-default/index.css

解决:修改路径为 element-ui/lib/theme-chalk/index.css

原因:elementUi升级时遗留bug


bug2: ERROR in static/js/app.77ab8a3664d32f2b9c76.js from UglifyJs

Unexpected token: operator (>) [./~/element-ui/src/mixins/emitter.js:2,0][assets/js/0.498ce690b229694d8858.js:3947,32

解决:打开build目录下webpack.base.conf.js文件

添加

{
  test: /\.js$/i,
  loader: 'babel-loader',
  include: [
    resolve('src'),
    resolve('test'),
    resolve('node_modules/element-ui/src/mixins/emitter.js'),
  ],
},

若重复build不断有类似错误,添加

  test: /\.js$/i,
  loader: 'babel-loader',
  include: [
    resolve('src'),
    resolve('test'),
    resolve('node_modules/element-ui/src'),
    resolve('node_modules/element-ui/packages')
  ],
},

你可能感兴趣的:(IT)