-
Notifications
You must be signed in to change notification settings - Fork 27k
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
make static css immutable #5675
Conversation
Also related to vercel/next-plugins#243 |
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.
wrong button.
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 don't think this is needed when we have vercel/next-plugins#335 🤔
I started with the other (#335) and it fixed some but not all the css max-age=0. So I hunted down what was adding immutable and it seems like there are two different type of static css and this gets the other one. I tried clearing my browser cache, .next, node_modules/.cache to be sure...it couldn't hurt for someone to double check though. |
I don't think we should put the implementation detail of a Next.js plugin inside of the Next.js core, especially when it doesn't add anything in this case because you've fixed the root cause of the issue. |
This doesn't exist in next-css. next-css only bundles everything into 1 file. |
Interesting. So my pages are following the "with-reasonml" example and my reason-react pages call bindings like this that require antd less/css from node_modules like this: Ultimately the ant design styles that get required for each of my pages ends up being served maxage=0 by next.js in a chunk for each page like this: |
Example reproduction here: https://github.com/Enalmada/next-reason-boilerplate I am using ant design and their babel-plugin-import. I am under the impression that is just automatically adding requires for css I need and I assumed next-css would handle it from there but perhaps not, perhaps require calls skip next-css. The css still ends up being served by nextjs so I think this fix is the only way to handle it. |
Can we merge this? It is definitely necessary to make the css files directly required by reasonml files immutable and I would love to get this fixed unless there is a better way to do that. |
@Enalmada just to catch me up, we think that there is an interop issue with the ReasonML integration that is causing the undesirable output of the css bundle under |
@jhoffmcd Thanks for taking a look at this! I am pretty sure the problem stems from either the way 3rd party reasonml bindings requires css files: example here, or the way babel-plugin-import auto-imports css which is usually used in conjunction with ant design. I did my best to fix but it is possible this fix could be implemented better/simpler. I feel like the whole static directory perhaps should always be immutable...I am unsure a chain of checks for different things is really necessary....why not just make everything from that directory always immutable? |
@Enalmada can you double check the version of The version you have installed on https://github.com/Enalmada/next-reason-boilerplate: The version with the path change to |
@jhoffmcd I updated the example repo with next-css:1.0.2-canary.2 and when running in production mode, it unfortunately only fixes one of 5 css files: 4 css files are still being served out of "/_next/static/css" rather than "/_next/static/chunks" and thus missing the fix in 1.0.2-canary.2. The mystery is what is the right way to get immutable on the rest of them. I am assuming the way they are being loaded is skipping next-css and a fix like this pull request is necessary but perhaps that assumption is wrong and they should end up being processed by next-css in a way I don't yet understand how to enable. |
@Enalmada Is is possible to get a reproduction with a smaller sub set of dependancies? The boilerplate you have set up integrates a large number of libraries and tooling and I would like to understand the source of the problem before we modify core behavior. Running canary versions of next and next-plugins alone, I cannot reproduce this outcome. If you think its |
Ok I take it back with egg on my face...you are right! Earlier I updated |
Awesome! No problem @Enalmada I'm glad you found the source! |
css is currently max-age 0 which means it won't be cached by cdn. This fixes that along with
Related: vercel/next-plugins#335
Fixes #5464
Fixes vercel/next-plugins#243