一、安装依赖

  1. yarn add html-webpack-plugin -S
  2. // 自动生成index.js文件

二、配置

  1. const HtmlWebpackPlugin=require("html-webpack-plugin")
  2. const config={
  3. .....
  4. plugins:[
  5. new HtmlWebpackPlugin({
  6. template:path.join(__dirname,'public/index.html')
  7. })
  8. ],
  9. mode:'development' // 模式
  10. }
  11. module.exports=config