-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use html-webpack-plugin templating features #7
Comments
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. |
Hi there! I was struggling for making templating and pre-rendering work together properly, and realized that the order of file processing should be changed. That seemed to me quite hard to do, so I came up with having a plugin instead of loader. That allows to render html that has been processed by all loaders, templating stuff etc., and do not interrupt/change the usual flow. Here is my version of the plugin, it's quite simple but worked for me: Its rendering code and idea in general fully based on prerender-loader project, but simplified just to make simple things without additional options. Hope this helps someone! |
@idudinov that looks great. I'm almost tempted to try to migrate this project to be a plugin, or provide both flavors in one module. Thoughts? |
Well, I see Webpack philosophy as a way when some new content/assets produced by plugins, but loaders just transform assets to another representation. |
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. |
🐛 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
is rendered by this plugin as
The text was updated successfully, but these errors were encountered: