template-ejs-loader icon indicating copy to clipboard operation
template-ejs-loader copied to clipboard

About the value of `htmlWebpackPlugin`

Open dc7290 opened this issue 3 years ago • 1 comments

Problems with this loader

Currently, the loader cannot use htmlWebpackPlugin values in ejs files. It cannot simply use the data in individual files, but also the values provided by default by html-webpack-plugin.

Message

I would like to solve this problem, but I am not sure how to make it possible. I would appreciate help from anyone who knows how to solve this.

Reference information

For reference, I will list the values of htmlWebpackPlugin for the various loaders that can be used and those that cannot. Based on these, we would like to find the conditions under which the htmlWebpackPlugin value can be used in a file.

Loaders for which the value of htmlWebpackPlugin can be used

  • handlebars-loader https://github.com/pcardune/handlebars-loader
  • twig-loader https://github.com/zimmo-be/twig-loader
  • pug-loader https://github.com/pugjs/pug-loader
  • html-loader https://github.com/webpack-contrib/html-loader

Loaders for which the value of htmlWebpackPlugin is not available

  • twig-html-loader https://github.com/radiocity/twig-html-loader

Supplementary information

Also add the expected conditions under which this value will be available in the file.

  • Single loader instead of chained loaders

dc7290 avatar Mar 15 '22 13:03 dc7290

This plugin looks useful but this problem prevented me from using it, so definitely a +1 for this feature from me.

For anyone wondering about a workaround, I ended up not using this plugin at all and just calling the EJS module directly, passing in htmlWebpackPlugin as one of the template variables, and then passed the rendered template to templateContent in HtmlWebpackPlugin.

tstibbs avatar Dec 02 '22 12:12 tstibbs