question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use html-webpack-plugin templating features

See original GitHub issue

🐛 Not able to use some of html-webpack-plugin’s templating features.

Example from https://github.com/jantimon/html-webpack-plugin/blob/master/README.md#generating-multiple-html-files

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

is rendered by this plugin as

<title>&lt;%= htmlWebpackPlugin.options.title %&gt;</title>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
developitcommented, May 31, 2018

This is actually more of an EJS problem - ejs templates don’t mix nicely with HTML. I don’t have a great recomendation right now other than to avoid using this with ejs templates. Handlebars should work fine, or skip templating altogether since you can just do:

// custom-prerender.js
export default function(params) {
  document.title = 'A Custom Title';
  return '<div>some prerendered html</div>';
}
<!-- template.html -->
<head>
  <title>Default Title</title>
</head>
<body>
  {{prerender:custom-prerender.js}}
</body>

For things folks might have been doing in ejs like script and stylesheet insertion, there are already automated html-webpack-plugin plugins that handle those things in a way that works nicely with prerender-loader.

0reactions
badpenguincommented, Jan 9, 2019

any of you has a working example with handlebars? i’ve an array of page objects with url, title, description, og:image, canonical and need to pass it into the template - i was looking at the preact-cli code that does the same but i failed to understand it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML webpack plugin not injecting script to template
Show activity on this post. const HTMLWebpackPlugin = require("html-webpack-plugin"); plugins: [ new HTMLWebpackPlugin({ template: "./src/index ...
Read more >
Processing HTML with a webpack Plugin
Loaders preprocess code that webpack can't directly work with, ... plugins: [ new HtmlWebpackPlugin({ title: 'Shape Tracker', template: '.
Read more >
html-webpack-plugin - npm
Simplifies creation of HTML files to serve your webpack bundles. Latest version: 5.5.0, last published: a year ago. Start using ...
Read more >
html-webpack-plugin | Yarn - Package Manager
Features ; drop webpack 4 and node <= 10 support to make use of the latest APIs (b7a9e8f) ; use the new webpack...
Read more >
Webpack 5: Setup Html Webpack Plugin - YouTube
Your browser can't play this video. ... Configure Webpack 5 to use html-webpack-plugin 02:18 Use a Custom Template with html-webpack-plugin ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found