Preview:
// 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
	},

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter