在webpack中打包生成的文件会覆盖之前的文件,不过生成文件的时候文件名加了hash之后会每次都生成不一样的文件,这就会很麻烦,不但会生成很多冗余的文件,还很难搞清楚到底是哪个文件,这就需要引入该插件
npm install –save-dev clean-webpack-plugin
1 //webpack.config.js 2 //引入clean-webpack-plugin 3 const CleanWebpackPlugin = require('clean-webpack-plugin'); 4 5 //plugin插入你想删除的路径,注意在生成出来文件之前,他会删除public的文件夹,而不是根据生成的文件来删除对应的文件,如果文件夹中所有的文件都是根据webpack生成的,,所以有什么额外的文件最好别引用这个!!! 6 new CleanWebpackPlugin(['public']);