1.webpack 配置

webpack 惯例配置如下(entry、output、loader、plugin、mode)

const path = require('path')const HtmlWebpackPlugin = require('html-webpack-plugin')module.exports = {  mode: 'development', // 模式  entry: './src/index.js', // 打包入口地址  output: {    filename: 'bundle.js', // 输入文件名    path: path.join(__dirname, 'dist') // 输入文件目录  },  module: {     rules: [      {        test: /\.css$/, //匹配所有的 css 文件        use: 'css-loader' // use: 对应的 Loader 名称      }    ]  },  plugins:[ // 配置插件    new HtmlWebpackPlugin({      template: './src/index.html'    })  ]}

2.手写一个 plugins 插件