美文网首页
npm run build时,webpack打包总是失败报错如下

npm run build时,webpack打包总是失败报错如下

作者: 小呆糊总 | 来源:发表于2020-04-16 17:35 被阅读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'),]
      },
    ]
  }

相关文章

网友评论

      本文标题:npm run build时,webpack打包总是失败报错如下

      本文链接:https://www.haomeiwen.com/subject/vqsdvhtx.html