-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[v2] use MiniCssExtractPlugin only on production builds #5057
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good idea — might be a little while until HMR is finished.
@@ -8,7 +8,6 @@ | |||
}, | |||
"dependencies": { | |||
"@babel/runtime": "^7.0.0-beta.42", | |||
"mini-css-extract-plugin": "^0.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was it removed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i they are following through with my changes in #4971 where i missed this one 😳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha 👍
code looks fine, thou maybe this isn't necessary? the plugin works with incremental builds, though yes it requires a hard refresh. Part of me thinks it's nicer to have them always extracted since it'll much closer to what the prod build will be, plus no flash of unstyled content. |
@jquense Yes I agree it's nicer to keep the behavior the same in different stage, I thought about adding a option to turn off the fallback to style-loader, but in practice we trend to only use text extract plugin in production only, we can change a bit to remove the fallback when the library supports HMR |
Sure, but most of the reason for that is the the old extract -text just couldn't be used reasonably outside of Prod, not because it makes sense to only use it there. I just wanted to chat a bit about the options here, reasonably i think that if we hit v2 and HMR is added after we can't update the default config without it being a breaking change (on the cautious side), If HMR is coming reasonably soon i'd say we should just keep it and wait for the improvement, but that's just me. Personally i think style-loader mostly causes issues (and dev only ones at that), i'd prefer the hard reload with a path towards the same thing automatically further on over using style-loader.
Yeah they are old, likely some plugins didn't get upgraded when the original PR switched the plugins out. |
I'm a bit indifferent about this PR too — though I only do css-in-js so don't feel any pain from CSS HMR not working :-D — I know Tobias wants to get HMR in fairly quickly 🤷♂️ I also don't think it'd be a breaking change to swap styled-loader out for native HMR once it's ready so... |
I only use styled-components too, but I'm building a website for a library using sass, so I need css HMR, I think the switching to style-loader in development is legit as when HMR is ready from mini css plugin, we can simply remove the tweak Any thoughts on this? or should I just remove the style-loader to only apply the other fixes? |
Yeah, this seems fine for now — we'll remove it soon enough. |
MiniCssExtractPlugin
should be used on production builds only as it doesn't support HMR right now, we can remove the fallback to style-loader when it supports HMRhttps://github.com/webpack-contrib/mini-css-extract-plugin#advanced-configuration-example
webpack-contrib/mini-css-extract-plugin#100