We'd like to render one of our React components to static HTML, so it's in the index.html returned by the server.
Rather than the code doing this while the server is being started, we'd rather the HtmlWebpackPlugin render the React component into its generated index.html. This is possible and it works very well; however, as soon as we attempt this with a React component that imports its SCSS, we see the following error:
Error: /Users/calumjames/htmlwebpackplugin-error-react-rendering/tools/webpack/indexRenderer:5396
return window && document && document.all && !window.atob;
^
ReferenceError: window is not defined
I've created a simple Git repo that examples the issue. As mentioned in the README file, if the line that imports the SCSS in the Loading
component is commented out, this error stops appearing and the component is rendered into the index.html correctly.
We could do with not changing how the component is coded because it's an internal shared component and the coding style matches the other shared components.
Is there something wrong with my code or config, or is there an issue with one of the Webpack plugins or loaders?