-
Notifications
You must be signed in to change notification settings - Fork 5
Description
First of all, thanks for creating this plugin. After trying my luck with static-site-generator-webpack-plugin and needing two different templates for SSR and client, this package solved all my problems. I just wanted to give a little feedback with my first impressions. I'm happy to submit some of these things as a PR if needed:
Needs html-webpack-plugin version 4.0
I spent half an hour try to get the plugin to work only to realize that it needs html-webpack-plugin version 4.0 to work. It would be great to state that in the README.
How to know it's a SSR render
When I got the rendering working, some code using the global navigator object broke, and I wanted to only run that code on the client side. In the docs, it looks like doing if(document.body) will do that, but the document body is also present via JSDOM during the Node render. I ended up adding a boolean to my scope:
new HtmlWebpackPrerenderPlugin({
'index.html': {
app: {
selector: '#root',
scope: {
isSSRRender: true,
}
}
}
})And then doing this in a utils file:
export const isSSR = typeof isSSRRender !== 'undefined';I can then use that variable to check whether it's running in Node or the client. This might be helpful for other people too.
new Plugin()
Some of the documentation README's has new Plugin(), which is confusing. This should probably be replaced with new HtmlWebpackPrerenderPlugin().
Hot module loader
This package, like static-site-generator-webpack-plugin does not work with the webpack dev server and hot module loading. It would be great to have a note that the plugin should only be added when running a production build.
That's all. Thanks!