npm run build时,webpack打包总是失败报错如下
2020-04-16 本文已影响0人
小呆糊总
npm run build时,webpack打包总是失败,最后发现时swiper版本问题导致
ERROR in static/js/3.d01bcc22c94d9c3efc50.js from UglifyJs
Unexpected token: name (Dom7) [static/js/3.d01bcc22c94d9c3efc50.js:8780,6]
ERROR in static/js/5.1af5c8bc024d7163cb1f.js from UglifyJs
Unexpected token: name (Dom7) [static/js/5.1af5c8bc024d7163cb1f.js:741,6]
错误截图.png
解决方案:
swiper版本问题,修改位置build/webpace.base.conf.js
增加resolve('node_modules/dom7'),resolve('node_modules/swiper')
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['env', 'stage-2']
},
include: [resolve('src'), resolve('test'),resolve('node_modules/dom7'),resolve('node_modules/swiper'),]
},
]
}