作用:
1.自动在内存中根据指定的页面生成一个内存的页面
2.自动,把打包好的bundle.js 追加到页面中去
1、运行 npm i html-webpack-plugin -D 安装
2、在webpack.config.js 中导入 html-webpack-plugin
const htmlWebpackPlugin = require("html-webpack-plugin")
3、在webpack.config.js 中配置插件
plugins: [ //配置插件的节点
new htmlWebpackPlugin({ //创建一个 在内存中 生成 HTML 页面的插件
template: path.join(__dirname, './src/index.html'), //指定 模板页面,将来会根据指定的页面路径,去生成内存中的 页面
filename: "index.html" //指定生成的页面的名称
})
]