// 1. import const HtmlWebpackPlugin = require("html-webpack-plugin"); // 2. add the plugin in config { //.... plugins: [ new HtmlWebpackPlugin({ title: "vanillaJS app", template: path.resolve(__dirname, "src", "index.html") }) ], // 3. add clean:true to output to keep the dist folder clean output: { filename: "main.js", path: path.resolve(__dirname, "dist"), clean: true // <---- one more addition }, }