0

Full disclosure: I'm new to webpack and trying to figure out some of the "magic" that seems to happen behind the scenes.

In this page https://github.com/jantimon/html-webpack-plugin there is some sample code like this:

<title><%= htmlWebpackPlugin.options.title %></title>

It seems that some kind of templating engine is running at build time to substitute the value of these variables. I've also seen other examples with <% ... some js code %>.

I just want to know how the templating works and where it is documented. Is it somehow built into webpack itself? Is it an explicit loader? Is it part of htmlWebpackPlugin or can I use it with any loader? I've tried searching for the answer but searching for <%= in google is very hit-and-miss

1 Answer 1

0

The documentation has options that you can use for the template file

Take a look at it for all the options available

From the documentation:

htmlWebpackPlugin: data specific to this plugin

webpack: the webpack stats object

webpackConfig: the webpack configuration that was used for the compilation.

compilation: the webpack compilation object

The htmlWebpackPlugin again has two options files and options. If you want to send any user defined values use the htmlWebpackPlugin.options

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.