-
Notifications
You must be signed in to change notification settings - Fork 85
CSS Chunk not hot reloading with Webpack 4 #80
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
Comments
I'm also having a similar issue. I'm not using universal and I'm using splitChunks cacheGroups to combine my CSS into a single file: cacheGroups: {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true
},
}, But otherwise have hot reloading turned on and ready to go: new ExtractCssChunks({
filename: 'css/[name].css',
chunkFilename: 'css/[id].chunk.css',
hot: true,
}), I am also using CSS modules with postcss but I don't think that would affect anything? |
Relocating to the west coast. Should be able to pick things up properly after the 4th :) |
Congrats on the move! I’ve got my system nominally working and have backup plans (re-introducing style-loader in dev mode) for the mean time. Can’t speak to op though obviously. |
Okay good I’m glad you are sorted for the time being. Thanks for posting a repo example, I’ll definitely check it. Thanks man, it’s been a loooong drive 😂 |
Welcome to the west coast @ScriptedAlchemy! I haven't had a chance to look into this further with the break but should be able to get to it soon. Let me know if there's any more info I can provide to help out. |
Pulling this repo down today, running on a 4G link so capacity is still heavily diminished. Ill see if i can find the issue today though :) |
Okay, so, for my own sanity.. I pulled up some of my own infra and flipped them over to CSS modules. Which seems to work flawlessly. So while this issue is definitely real and reproducible. It might be configuration related. Ill need some more time to debug this demo and see whats gone off. Only difference is im using SCSS |
While mine works, Its also a extremely complicated setup. |
Sounds good. FWIW, I have another project going where I am using SCSS and CSS modules and this behavior still shows up. |
@sjwood25890 okay, ive got the biggest hack ever, buuuuut - for today, it will get everyone back on their feet. Im gonna publish a beta of it and we will see how goes |
Now available on npm Let me know if it solves the immediate issue. Ill continue to investigate better solutions If you can test it tomorrow, ill merge: https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/pull/82/files |
@sjwood25890 Had a chance to test it on your side? |
@ScriptedAlchemy just got to it, but yes that provide a workaround for now. Thanks! |
Perfect! thank you. Ill merge this and re-write HMR when i can |
* fix(src): CSS Modules HMR [PATCH] Short term solution to get css modules to hot reload for everyone. fix #80, #77 * style: Linting and generalized updates basic updates to code, linting, new yarn lock and so on * placeholder changed at version * fix(order): use correct order when multiple chunk groups are merged
@ScriptedAlchemy I still have this problem, even on entry: {
index: path.resolve(paths.src, "index.js")
} optimization: {
runtimeChunk: {
name: "vendors"
},
splitChunks: {
chunks: 'all',
name: 'vendors',
cacheGroups: {
vendorStyles: {
name: "vendors",
test: path.resolve(paths.src, "sass/vendors.scss"),
chunks: "all",
enforce: true
}
}
}
} my index.js (entry point) is nothing more than: require('./js/vendors');
require('./js/site'); and the end of js/vendors.js (after importing packages from node modules): import '../sass/vendors.scss';
if (module.hot) {
module.hot.accept('../sass/vendors.scss', function(){
console.log('VENDORS.CSS ACCEPTED');
});
} When I modify any [WDS] App updated. Recompiling...
[WDS] App hot update...
[HMR] Checking for updates on the server...
VENDORS.CSS ACCEPTED
[HMR] Updated modules:
[HMR] - ./resources/assets/sass/vendors.scss
[HMR] App is up to date.
[HMR] css reload http://localhost:8080/build/index.css .. and in the browser index.css gets updated instead of vendors.css Tested with latest Webpack |
When using oneOf, HRM is never activated. This patch improved the lookup system used for determining if CSS can and should be reloaded. There have been some other tweaks for css modules and HMR fix faceyspacey#98,faceyspacey#80
* fix: Fixed HMR issue when oneOf is used When using oneOf, HRM is never activated. This patch improved the lookup system used for determining if CSS can and should be reloaded. There have been some other tweaks for css modules and HMR fix #98,#80 * fix: Applying rollback fixes to updateWebpackConfig, search loader and use object keys * fix: Adding back exported out hot loader * docs(readme): Adding example of manual hotloader implementation In the event users cannot get it to work, theres an example in the docs to reference * fix: handle functions as loaders Do not break when searching through `use` or `loader` that is a function * fix(index.js): Support function loaders (#116) * docs(readme): Tone of Voice clairification on what hot:true does (#113) * fix(index.js): Support function loaders updateWebpackConfig previously expected `use` entries to be strings or arrays, and would throw `needle.includes is not a function` errors when given a function that returns a loader object. * Update README.md * test: Fixing function-loader tests * Add reloadAll and cssModules to typings (#115) * docs(readme): Tone of Voice clairification on what hot:true does (#113) * Add reloadAll and cssModules to typings
As was partly reported in #75, with Webpack 4 CSS chunks loaded with react-universal-component are not being hot reloaded correctly for me. That issue was closed so I wanted to restart the conversation here.
The hot reload is being accepted by the client but the main.css file is being reloaded instead of the specific CSS chunk. In my fork of the Universal Demo for Webpack 4, when I change an async component's CSS the console shows:
I'm expecting that it should reload http://localhost:3000/static/components-Foo.css.
Versions:
node 10.2.1
react-universal-component 3.0.0-alpha.2
webpack-flush-chunks 2.0.1
extract-css-chunks-webpack-plugin 3.0.5
Project showing behavior:
https://github.com/sjwood25890/universal-demo/tree/webpack-4-RUC-3
FWIW, digging around in
hotModuleReplacement.js
shows me thatgetCurrentScriptUrl
is always returning the main.js file instead of the chunk's JS file. If I force areloadAll()
on every CSS hot update I get the desired result on the client, which is obviously not the ideal way to do this, but does make me think the issue is in identifying which CSS file to reload inhotModuleReplacement.js
.The text was updated successfully, but these errors were encountered: