1. 10
    Inject a JavaScript bundle into HTML with the HtmlWebpackPlugin
    3m 1s

Inject a JavaScript bundle into HTML with the HtmlWebpackPlugin

InstructorAndy Van Slaars

Share this video with your friends

Send Tweet

Even if it's only a simple one, we'll need to serve up an HTML file to run our JavaScript app. We can hardcode the bundle path into a script tag, but then if we want to change our bundle name, we need to update that in our webpack config and in our html file. In this lesson, we'll see how to use the HtmlWebpackPlugin to inject the script tag for our bundle into an HTML template file.

Fisker Karma
~ 6 years ago

At this step, I am getting the following error: Uncaught Error: Target container is not a DOM element in console and in terminal, a verbose error log saying how it doesnt recognize html template. Please help with this. Thanks!

AJ Villalobos
~ 6 years ago

You can try downloading the github code from this episode and compare. I had a problem too earlier, the console is outputting a.render is not a function. Silly typo where I imported react instead of react-dom.

AJ Villalobos
~ 6 years ago

You can try downloading the github code from this episode and compare. I had a problem too earlier, the console is outputting a.render is not a function. Silly typo where I imported react instead of react-dom.

Denis OSullivan
~ 3 years ago

I installed latest htmlwebpackplugin and configured but when I ran the build I received this error "TypeError: Cannot read property 'tap' of undefined" in the terminal

I fixed by installing the same version in the video https://github.com/avanslaars/egghead-react-boilerplate/blob/09_html_webpack/package.json#L27 (not the latest version)