From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using the HtmlWebpackPlugin

Using the HtmlWebpackPlugin

From the course: Learning webpack 4

Start my 1-month free trial

Using the HtmlWebpackPlugin

- [Instructor] Another nice feature to use in your project is the HtmlWebpackPlugin. This is going to generate an HTML file that links to the bundle. So I'm going to go ahead and npm install html-webpack-plugin and I'll save it to our dev dependencies. Now over in the code, I need to make a few adjustments. So let's make sure that we're in 04_04, start, and we'll grab the webpack.config. So we have these multiple entry points. I want to first start by getting rid of these. So I'll say ./src/index.js. And then I'm just going to export everything to the main file. Now the next thing I want to do is to add another key here, called plugins, and you can add this anywhere in the object. Plugins, should take in this array. And I'm going to use new HtmlWebpackPlugin. And I also need to import this, const HtmlWebpackPlugin and we'll require it. Okay. So now I want to do something in the dist folder. And that is to just go ahead and delete everything that's there. So this is scary to do, but…

Contents