打包html方法
- 使用插件(plugins)对HTML文件进行处理(html-webpack-plugin)
- 下载安装 npm i html-webpack-plugin -D
- 引入插件 const HtmlWebpackPlugin = require(‘html-webpack-plugin’)
- 使用插件
plugins: [
new HtmlWebpackPlugin({
template:'./src/index.html',
filename:'./html/index.html',
chunks:['index'],
minify:{
collapseWhitespace:true,
removeComments:true
}
})
]
打包多个html
```javascript
* plugins: [
new HtmlWebpackPlugin({
template:'./src/index.html',
filename:'./html/index.html',
chunks:['index'],
minify:{
collapseWhitespace:true,
removeComments:true
}
}),
new HtmlWebpackPlugin({
template:'./src/about.html',
filename:'./html/about.html',
chunks:['about'],
minify:{
collapseWhitespace:true,
removeComments:true
}
}),
]