-
Notifications
You must be signed in to change notification settings - Fork 27
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
Direct integration with mini-css-extract-plugin #14
Comments
Hi @jantimon
This sounds great! Would you please describe a bit more in detail what you mean with adding hooks? if (renderedModules.length > 0) {
// tapable hook here with possibility to modify the result
// and adjust the chunk (by removing the extracted CSS)
result.push({
render: () =>
...
Sounds like presets – I really like this idea, too :) However the rework of the plugin (closer to |
Yes that's exactly what I had in mind about the I just came across one issue with the media query splitting approach in general.
The background would always be Do you think that's a big issue? |
Ok, I need to check the code more in detail to know if/how this can be achieved.
We also discussed this in the team when talking about media query extraction and right, it may cause the side effects you described. Example: // framework
h1 {
font-size: 1rem;
}
@media screen and (min-width: 40em) {
h1 {
font-size: 1.5rem;
}
}
// custom
h1 {
font-size: 2rem;
}
I think it requires a very good structure of your CSS and knowledge about specificity. A methodology such as BEM can help you to avoid those problems. Imo the media query extraction just reveals problems of the own structure if it causes problems and instead of abandoning it you should try to improve your code to get rid of the side effects. Splitting is a powerful way to significantly improve the page performance – if done correctly. |
Hey @SassNinja
it took me way to long to discover this repo.
In many projects we face the problem your plugin is trying to solve.
I had an idea which would probably cause a lot of work but should simplify the configuration and performance of your plugin.
What if the
mini-css-extract-plugin
would introduce a hook here:https://github.com/webpack-contrib/mini-css-extract-plugin/blob/b653641e7993eb28fad70c1733dc45feafea93c5/src/index.js#L200
and here:
https://github.com/webpack-contrib/mini-css-extract-plugin/blob/b653641e7993eb28fad70c1733dc45feafea93c5/src/index.js#L174
So you could split the files generated by mini-css-extract-plugin whenever they are generated or regenerated.
The configuration could look like the following:
Maybe you could also provide some defaults e.g. split print styles and all styles for viewports larger than (e.g.) 1000px ?
This would provide an awesome zero config experience and people could just add the plugin to every project without worrying about details. (at least for basic usage)
The text was updated successfully, but these errors were encountered: