When I run 'npm run dev' in the terminal ,the error shows. However when I run 'npm run build', it can run sucessfully. I think my webpack version is too high to compat the plugin (e.s. uglifyjs-webpack-plugin) Thanks to every hand that help me.
webpack-dev-server
[webpack-cli] TypeError: compiler.plugin is not a function
at UglifyJsPlugin.apply
And here is mian part of my package.json.
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.2.2",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^2.0.2",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^5.3.2",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"style-loader": "^3.2.1",
"uglifyjs-webpack-plugin": "^1.1.2",
"url-loader": "^1.1.2",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.1",
"webpack": "^5.51.1",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.1.0"
},
"dependencies": {
"vue": "^2.6.1"
}
the webpack.config.js :
mode:'development',
plugins: [
// make sure to include the plugin for the magic
new VueLoaderPlugin(),
new webpack.BannerPlugin(''),
new HtmlWebpackPlugin({
template:'./index.html'
}),
new UglifyJsPlugin()
],
devServer:{
contentBase:'./dist',
inline:true
},