You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Reading the main docs, I naively assumed that the only real difference between template and templateContent was that template read the content from a file for you. I had assumed that I could take the contents of the file I was providing and instead provide the contents to templateContent and get equivalent output. However, this does not appear to be the case. Example:
Feature request: I would personally like if strings passed to templateContent would do templating in the same way as files passed to template. Making these consistent would give some advantages, for example I could then use the same template language in both, making it easier to share snippets between different templates. Additionally, not all of my templates are in files. For example, in one case I am reading an html file (provided by an up-stream project) and doing some regex replacement on it to turn it into a template. I'd prefer not to have to write that modified template in to a file just so it can go through the templating engine, it would be simpler to just pass the parsed html directly to HtmlWebpackPlugin.
Doc bug report: the doc for templateContent doesn't (in my view) make this difference clear. The doc on writing your own template does repeatedly give a warning saying "templateContent does not allow to use webpack loaders for your template" - if that's the reason for the behaviour I'm seeing then I didn't infer that from the warning text, so I think it could be make clearer.
Describe alternatives you've considered
The obvious simple workaround is to write the template to a temp file first, which is annoying but not difficult. Raising this ticket because even if the feature request is rejected (on the basis of a simple workaround), I think the docs could be clearer on this point.
Is your feature request related to a problem? Please describe.
Reading the main docs, I naively assumed that the only real difference between
template
andtemplateContent
was thattemplate
read the content from a file for you. I had assumed that I could take the contents of the file I was providing and instead provide the contents totemplateContent
and get equivalent output. However, this does not appear to be the case. Example:Using
template
config:
index.html.ejs:
generated index.html:
Using
templateContent
config:
generated index.html:
Describe the solution you'd like
Feature request: I would personally like if strings passed to
templateContent
would do templating in the same way as files passed totemplate
. Making these consistent would give some advantages, for example I could then use the same template language in both, making it easier to share snippets between different templates. Additionally, not all of my templates are in files. For example, in one case I am reading an html file (provided by an up-stream project) and doing some regex replacement on it to turn it into a template. I'd prefer not to have to write that modified template in to a file just so it can go through the templating engine, it would be simpler to just pass the parsed html directly to HtmlWebpackPlugin.Doc bug report: the doc for
templateContent
doesn't (in my view) make this difference clear. The doc on writing your own template does repeatedly give a warning saying "templateContent does not allow to use webpack loaders for your template" - if that's the reason for the behaviour I'm seeing then I didn't infer that from the warning text, so I think it could be make clearer.Describe alternatives you've considered
The obvious simple workaround is to write the template to a temp file first, which is annoying but not difficult. Raising this ticket because even if the feature request is rejected (on the basis of a simple workaround), I think the docs could be clearer on this point.
Additional context
Node.js v16.18.1
npm: 8.19.3
webpack: 5.75.0
html-webpack-plugin: 5.5.0
The text was updated successfully, but these errors were encountered: