-
Notifications
You must be signed in to change notification settings - Fork 127
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
Running webpack-dev-server caches generated static html content #35
Comments
Additional problem here that I also notice with using |
Hey @alicoding, thanks for the issue :) The goal of
As for the second issue, I'm seeing the same thing. If I make changes to |
@alicoding Below is way too much info about this issue, but I wanted to document my findings at least. So the issue is that the generating html portion of the process isn't using webpack loaders so it ends up being tied to the fact that node caches Here's some code that ends up working for the html: function (data) {
var pages = {};
var pageRequires = {
'index.html': './src/home-page.js',
'other/index.html' : './src/other-page.js'
};
Object.keys(pageRequires).forEach(function (page) {
// Generate the full require path since that is what is used for the require.cache key
var requirePath = path.resolve(__dirname, pageRequires[page])
// Delete from the require cache
delete require.cache[requirePath]
// Require the page again
pages[page] = data.defaultTemplate({
html: React.renderToString(React.createElement(require(requirePath)))
});
});
return pages;
} We had discussed previously (#24 (comment)) using a different html plugin but looking at the issues for that project, it has an open issue for the same thing and also an open PR which might fix it. I subscribed to that PR on GitHub so I'll keep tabs on when it gets merged. I propose that once that happens we take a look at implementing it within |
Hey @lukekarrys :) I end up using this plugin in the meanwhile https://www.npmjs.com/package/simple-html-precompiler for generating HTML... for now at least. |
Hey folks, yeah. I agree this is all a bit wonky. Frankly, testing pre-rendering locally is a bit weird, just because it won't automatically be live-reloaded or even refreshed as you said. But... having said that. I've been building apps this way and I think this limitation is tolerable. I've been using the I'm closing this issue for now, until we've got some sort of actionable plan. |
I'm using this example here https://github.com/HenrikJoreteg/hjs-webpack/tree/master/examples/prerendered-html-files
When I run
npm start
which iswebpack-dev-server
it doesn't seem to generate the static files*/index.html
for some reason. I had to runwebpack
first in order to get that work.The text was updated successfully, but these errors were encountered: