1.生产一个html文件

  1. cnpm i html-webpack-plugin -S
  2. //自动生成index.html文件
  1. ...
  2. +const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const config = {
  4. ....
  5. + plugins:[
  6. + new HtmlWebpackPlugin({
  7. + title:"webpack-vue",
  8. template:path.resolve(__dirname,"public/index.html")
  9. + })
  10. + ],
  11. mode:'development' //模式
  12. }
  13. module.exports = config;

2.清除dist文件夹

  1. cnpm i clean-webpack-plugin -S
  2. //清除dist目录下需要的文件
  1. + const {CleanWebpackPlugin} = require("clean-webpack-plugin");
  2. const config = {
  3. ...
  4. plugins:[
  5. ...
  6. + new CleanWebpackPlugin()
  7. ],
  8. mode:'development' //模式
  9. }