vue 打包失敗問題UglifyJs

                                            vue 打包失敗問題

   

          在編譯build vue工程時,突然提示ERROR in static/js/vendor.ce4ce2fbafc7c2a943bd.js from UglifyJs如下錯誤。

          這個是由於 UglifyJs 只支持 ES5 ,而 vue-echarts可能引入了一部分 ES6 的寫法,所以導致 webpack 打包失敗。

ERROR in static/js/vendor.ce4ce2fbafc7c2a943bd.js from UglifyJs
Unexpected token: name (raf) [./node_modules/resize-detector/esm/index.js:1,0][static/js/vendor.ce4ce2fbafc7c2a943bd.js:19238,4]

  Build failed with errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node build/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

 

解決辦法: 工程/build 目錄下的webpack.conf.js 文件增加如下配置,用 babel 解析。

報其他類似錯誤的,也可嘗試加下對應modules。

{
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'), resolve('node_modules/resize-detector')]
},

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章