打包html资源
使用webpack打包html资源
- 安装插件 html-webpack-plugin ,注意版本号为 4.5.0
- 其中指定模板为自己的html模版位置
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HtmlWebpackPlugin({
//指定自己的html模板位置
template: './src/index.html'
})
],
mode: 'development'
}