我想添加一個UglifyJS插件到我的webpack配置。入口點是簡單的,看起來像這樣:webpack - UgifyJS失敗
import Vue from 'vue';
import Comp from './components/comp.vue';
Vue.component('somecomponent', {
render: h => h(Comp)
});
,當我嘗試運行的WebPack它拋出一個錯誤:
ERROR in source1.bundle.js from UglifyJs
Unexpected token: operator (>) [./frontend/source1.js:7,0][source1.bundle.js:80,15]
我缺少什麼?這是我的配置
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
source1: './frontend/source1.js',
source2: './frontend/source2.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'static/bundles')
},
plugins: [
new CleanWebpackPlugin(['static/bundles']),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
})
],
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
}
}
]
},
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js'
}
}
};
是的,我得到了相同的結果。但是,我添加了Babel loader和「es2015」預設,並且錯誤消失了。謝謝! – kurtgn