Front end developers must read! Starting from scratch, teach you to build a low code website platform in stages>>>
Introduce clean webpack plugin into the project and report an error after packaging
new CleanWebpackPlugin(),
^
TypeError: CleanWebpackPlugin is not a constructor
Project writing method:
Introduction: cnpm Iclean webpack plugin – D
In webpack.config.js
const CleanWebpackPlugin = require('clean-webpack-plugin')
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html'
})
],
After looking at the writing method on githup, the introduction of clean webpack plugin in the new version has been changed to const {clean webpack plugin} = require (‘clean webpack plugin ‘)
So it’s OK to modify and introduce the writing method
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html'
})
],
Similar Posts:
- Webpack reports an error when using the cleanwebpackplugin plug-in
- [Solved] Vue cli 3.0 error: “Failed to load resource: net::ERR_FILE_NOT_FOUND”
- Webpack high version pulls out CSS style and reports an error [Solved]
- Webpack introduces HTML webpack plugin and reports an error
- Vue configures the compression-webpack-plugin to package and compress JS and CSS Error
- Causes and solutions of error reporting in require setting dynamic path
- Webpack 4 : ERROR in Entry module not found: Error: Can’t resolve ‘./src’
- WebPack Task Runner
- Webpack packaging error: cannot find module ‘webpack / bin / config yargs’ error reason, [email protected] Step on the pit~
- Maven warnning: ‘build.plugins.plugin.version’ is missing [How to Solve]