es6不能直接被uglify压缩,node_module里面的第三方包都会被默认忽略转译为es5。这里把你报Uglify错的所有包exclude进去config.module即可。例如你现在是swiper。在nuxt.config.js里面的build的extend里增加 config.module.rules.push({ test: /\.js$/, loader: 'babel-loader', exclude: function(modulePath) { return /node_modules/.test(modulePath) && !/node_modules\/swiper/.test(modulePath); }, options: Object.assign({}, this.babelOptions) }) 但是我在本机上述代码无效(window),但是在mac下有效。后来我用下面的替换就可以了。 config.module.rules.splice(0, 0, { test: /\.js$/, include: [path.resolve(__dirname, './node_modules/swiper')], loader: 'babel-loader', })
es6不能直接被uglify压缩,node_module里面的第三方包都会被默认忽略转译为es5。这里把你报Uglify错的所有包exclude进去config.module即可。
例如你现在是swiper。
在nuxt.config.js里面的build的extend里增加
但是我在本机上述代码无效(window),但是在mac下有效。后来我用下面的替换就可以了。