Skip to content

Feedback #2

@runemadsen

Description

@runemadsen

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions