我正在使用官方Vue Webpack template。
Webpack附带的UglifyJs无法编译ES6。所以我更改了Webpack插件的standalone version:
// webpack.prod.conf.js
var UglifyJsPlugin = require('uglifyjs-webpack-plugin')
new UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 8,
parse: {},
mangle: {
properties: {
// mangle property options
}
},
output: {
comments: false,
beautify: false,
},
compress: {},
warnings: false
}
}),
当我执行npm run build
时,应用会正确编译。但是,当我执行npm start
并访问localhost:3000
时,我收到此错误:
vendor.dc780f28ecc8d64eb53a.js:1 Uncaught ReferenceError: webpackJsonp is not defined
at vendor.dc780f28ecc8d64eb53a.js:1
(anonymous) @ vendor.dc780f28ecc8d64eb53a.js:1
app.470f1cb076c387c73cdc.js:1 Uncaught ReferenceError: webpackJsonp is not defined
at app.470f1cb076c387c73cdc.js:1
(anonymous) @ app.470f1cb076c387c73cdc.js:1
babel-polyfill.fc14d31ef0450ee23f4b.js:1 Uncaught ReferenceError: webpackJsonp is not defined
at babel-polyfill.fc14d31ef0450ee23f4b.js:1
可能是什么原因?
答案 0 :(得分:1)
尝试使用:
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js', Infinity)