Right way to split css into critical and non-critical style files #77518
Unanswered
sanjithkumar017
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
What would be the right way to handle styles in a large application? We are loading a single css for our whole application today and we would like to stick to it for historical reasons.
We are currently trying out two different approaches(links to the repo with minimal code)
This would require a huge effort from us to refactor our styles to allow webpack to bundle critical styles and non-critical styles separately. This seems to be the best option we have at the moment.
Configure a webpack plugin which uses purgecss(allow purge to decide which css is needed. But is not 100% foolproof in my opinion) internally and spits out two css files: original css(lazy load) and critical css(preload). The issue with this approach is that nextjs does not treat the purged(critical) css file as a part of the build. It is not listed in the
.next/build-manifest.json
file. We reply on build-manifest.json to power our document on production builds.Is there a better way to do this?
Additional information
Example
https://github.com/sanjithkumar017/next12-styling-webpack-demo
Beta Was this translation helpful? Give feedback.
All reactions