鍍金池/ 問答/HTML/ vue-cli run dev正常,運(yùn)行run build提示出錯(cuò),webpac

vue-cli run dev正常,運(yùn)行run build提示出錯(cuò),webpack已resolve相關(guān)modules


ERROR in static/js/vendor.cce10fda4a9a074cd1d7.js from UglifyJs
Unexpected token: punc (() [./~/_dom7@2.0.0@dom7/src/methods.js:7,0][static/js/vendor.cce10fda4a9a074cd1d7.js:10294,10]

  Build failed with errors.

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-09-29T12_05_58_655Z-debug.log

根據(jù)回答,我試了一下將dom7這個(gè)modules也加入到webpack的babel-loader:

 {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'),resolve('node_modules/_dom7@2.0.0@dom7/src')]
      },

接下來顯示的卻是:

ERROR in static/js/vendor.b4322554ee076d6e4c5e.js from UglifyJs
Unexpected token: name (w) [./~/_swiper@4.0.0-beta.4@swiper/dist/js/swiper.module.js:16,0][static/js/vendor.b4322554ee076d6e4c5e.js:11543,4]

  Build failed with errors.

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-09-29T17_13_49_547Z-debug.log

感覺這樣子下去要沒完沒了了。
然后我再:

      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'),resolve('node_modules/_dom7@2.0.0@dom7/src'),resolve('node_modules/_swiper@4.0.0-beta.4@swiper')]
      },

最后


> node build/build.js

? building for production...Killed

這是什么情況?如果我想引入這個(gè)插件我應(yīng)該如何配置這個(gè)webpack?

回答
編輯回答
旖襯

我是vue-cli架的手腳,我用swiper也是報(bào)一樣的錯(cuò)誤,用這個(gè)vue-awesome-swiper,在swiper進(jìn)行vue封裝,用起來一毛一樣 壓縮不出錯(cuò),

import { swiper, swiperSlide } from 'vue-awesome-swiper'

clipboard.png

2017年1月10日 18:40
編輯回答
巷尾

有可能內(nèi)存不足,你看看

2018年8月11日 23:12
編輯回答
生性

看來這個(gè)問題很嚴(yán)重啊,不寫這個(gè)exclude規(guī)則,vue項(xiàng)目引入swiper,在部分低級(jí)的手機(jī)瀏覽器里白頁,加上exclude規(guī)則,vue-lazyload、vconsole報(bào)錯(cuò),不知道該怎么解決了,swiper官方不修復(fù)這些問題?

2018年8月16日 13:35
編輯回答
愛礙唉

看起來像是在使用 UglifyJs 壓縮的時(shí)候有了問題,打包的時(shí)候打進(jìn)了內(nèi)置的模塊,壓縮出現(xiàn)了問題。很可能是 ES6 的問題?可以手動(dòng)升級(jí)一下 uglify 的版本重新試試。

2018年4月27日 20:30