2个插件的使用简介:
html-webpack-plugin:用于生成index.html替换我们原来的index.html
npm install --save-dev html-webpack-plugin
在配置文件里配置如下:先引入再在plugin里实例化
具体可参考:https://github.com/jantimon/html-webpack-plugin或https://github.com/jaketrent/html-webpack-template
clean-webpack-plugin在build的时候用于自动清理我们上一次生成的文件
npm install clean-webpack-plugin --save-dev
同样是在配置文件里先引入
const CleanWebpackPlugin = require('clean-webpack-plugin');
然后实例化
// new CleanWebpackPlugin(['web'], {
// root: path.resolve(__dirname, '..'),
// dry: false // 启用删除文件
// }), 2.0之前的版本
new CleanWebpackPlugin()
其中注释部分是2.x.x版本之前的写法,详细配置见 https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional
WebpackManifestPlugin,通过 manifest,webpack 能够对「你的模块映射到输出 bundle 的过程」保持追踪。构建后会生成例如以下文件和文件内容,源文件与编译文件之间的映射
用法类似以上,详情见https://github.com/danethurber/webpack-manifest-plugin