examples/html-template/template.md
This example demonstrates the experimental HTML modules support together with
the module.parser.html.template option, using Eta as
the templating engine. template compiles each HTML entry to plain HTML
before webpack parses it, so the URLs the template emits (the ``
source and the <script src>) are still discovered and bundled as regular
webpack dependencies.
It shows three things:
src/index.html is rendered with Eta and a data object
(title, list items, image URL).includes a partial
(src/footer.eta). Eta resolves partials by reading files, so the config
wraps eta.readFile to record every partial read and calls the context's
addDependency for each, so editing footer.eta triggers a rebuild and
invalidates the cache even though it never becomes a webpack module.src/special.html is matched by a module.rules
entry that hands it a differently-configured Eta (custom {{ }} tags,
autoEscape disabled) and its own data. rule.parser merges over
module.parser.html, so that template wins only for the matched file._{{webpack.config.js}}_
Default Eta tags (<%= %>), with an include and a <script src>.
_{{src/index.html}}_
An Eta partial pulled in via include(...). Registered as a build dependency
through addDependency, not bundled as a module.
_{{src/footer.eta}}_
_{{src/app.js}}_
Custom Eta tags ({{= }}) and unescaped output, selected by the rule.
_{{src/special.html}}_
_{{dist/index.html}}_
_{{dist/special.html}}_
_{{stdout}}_
_{{production:stdout}}_