-
Notifications
You must be signed in to change notification settings - Fork 105
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悶 CSS won't hot-reload on SSR'ed page #106
Comments
Wow 馃槸 thanks for the detail! I鈥檒l investigate this today or tomorrow 鉂わ笍鉂わ笍馃挴 |
@ScriptedAlchemy Thanks Zack. const reloaded = reloadStyle(src);
- if (reloaded && !options.reloadAll) {
+ if (!options.reloadAll || reloaded) {
console.log('[HMR] css reload %s', src.join(' '));
} else {
console.log('[HMR] Reload all css');
reloadAll();
} That could be an easy pull request for me, but I think that might just hide the real issue somewhere deep inside, that would explode into our faces later on. If it's dev-only we can probably take a risk, but if it has consequences for production builds, I'd prefer some more careful consideration :) |
Go ahead and open a PR!! HMR is all in dev anyways. Worst thing that may happen is something reloads more than required. I鈥檇 merge it into my branch and release another beta. Give it a few days and see if anyone complains. I think your issues were the last ones before rolling an update |
@ScriptedAlchemy Okay, upon further examination it turned out to be not so easy :). By the way, is it better to investigate and base my PR on |
Additionally I noticed that those erroneous "not reloading" reloads try to reload |
it would be best to PR multi hmr, thats the beta branch currently |
`options.reloadAll` had no effect, because they were incorrectly copied into the webpack's loader.options and could never reach `hotModuleReplacement.js`. This commit fixes the copy site, allowing for options to pass through. Fixes faceyspacey#106
PR #107 should fix {
new ExtractCssChunks({
filename: IS_DEVELOPMENT ? '[name].css' : '[name].[chunkhash:5].css',
chunkFilename: IS_DEVELOPMENT ? '[name].css' : '[name].[chunkhash:5].css',
cssModules: false,
reloadAll: true,
hot: true,
}),
} hot reloader will now reload all CSS perfectly at all times. However, setting this option just hides the fact that |
On first loaded (server-rendered) page CSS is not hot reloading, despite a report in browser console. It does not matter which page you are server-rendering. JS hot reloads fine on any page. CSS hot reloads fine on client-rendered pages too.
Repro:
Any commit will do in this repo, here is the last one:
https://github.com/ivan-aksamentov/reactlandia-bolerplate-lite/tree/781f3d0618770016c26b3a25ef23e746700e41d8
Quick start on Unix:
Scenario 1: "CSS on SSRed page is not hot reloaded" :
localhost:3000
in browser, "Home" page is loaded which is server-renderedbackground-color
.Scenario 2: "CSS on client-rendered page is hot reloaded" :
/
) in browser, without cache (Ctrl+F5)Scenario 3: "CSS on SSRed page is not hot reloaded on any page, not just Home":
/about
) in browser, without cache (Ctrl+F5), to obtain it's server-rendered copy this timeScenarios 5 and 6: "JS is hot reloaded just fine on both, server- and client-rendered pages"
Source files of interest:
What I tried:
{cssModules, reloadAll, hot}
ofextract-css-chunks-webpack-plugin
helps:options.reloadAll
has no effect for me, because the plugin always takes theif
branch here:extract-css-chunks-webpack-plugin/src/hotModuleReplacement.js:116 because of
reloaded
is true, but this reloaded actually did not reload anything.Workaround:
For comfortable dev experience I keep applying a monkey patch that deletes the
if
statement, so thatelse
branch (full hot reload) is always takenTODO
Look at DOM and see what hot-reload chunks are being added and in what order and how it differs in SSRed and client-rendered pages. It seems like it may be a CSS ordering issue.
The text was updated successfully, but these errors were encountered: