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
Sprinkles not applying in production build with NextJS App Directory #1085
Comments
Same problem encontered. |
Same issue encountered also |
Seeing the same issue w/ production build and agree it seems like it's related to how many sprinkles are being extracted. |
I've been hunting this down for the last couple hours. What I've found is the following:
It appears the All chunks are presented in this module entry, but not where they are used: {
// ...
"[REDACTED]/node_modules/@vanilla-extract/webpack-plugin/extracted.js#": {
"id": "null",
"name": "default",
"chunks": [
"static/css/033cde0f9a29e6bc.css",
"static/css/d600972155af5d3b.css",
"static/css/4d065bb72fe1c3b2.css",
"static/css/81c4a6d5521a7a63.css"
]
}
// ...
} |
This looks like an issue on the Next side. I'd suggest creating an issue on the Next repo. We can keep this open until it's resolved though. |
Sounds good, just created an issue over with Next. |
Just ran into this as well – I believe it's the same issue – locally, I am seeing class names such as |
looks like i've found a workaround: needs to disable {
webpack: config => {
config.optimization.splitChunks = false;
return config;
},
} |
@z4o4z – this worked for me, thank you for sharing! |
@z4o4z Excellent find. This seems to not be a sprinkles-specific issue, but rather breaks down when the amount of CSS is large enough. I created a test repository for demonstration. This commit breaks the build, as does uncommenting any more of the style objects currently commented out in the Like @z4o4z described, setting the |
yeah, it looks like the issue is related to mini-css-extract-plugin cause it generates chunks and files. I have an idea in mind how to disable chunks only for CSS, will try and let you know if that works. |
Thanks. The splitChunks workaround works but it's not a solution if it hurts performance causing large bundles. |
We've run into the same issue, the workaround also works so thanks @z4o4z . Hoping that a long-term fix is landing some time soon |
Well this workaround has a severe drawback of bloating the size of the lambdas that next creates for your server components, and we actually ran into the limit (50MB❗️) there. This idea about the fix you had @z4o4z, is it something that we could maybe do locally via the next.config's webpack hook? |
Not sure if this has been fixed but we are using |
It might depend on the size of your css. I just tried again with |
This issue seems to be resolved with the latest Vanilla Extract and Next builds |
Using the latest Vanilla Extract and Next 14 and it's still a major issue. |
@headline-design Please create a new issue with a reproduction if you're still encountering this issue. |
Describe the bug
Once sprinkles reach a certain size, NextJS production builds no longer import the needed CSS files. While running in development mode, everything works great.
I have created a minimal reproduction of the issue. If you go in and comment out any 1 of the sprinkle conditions in
./src/styles/sprinkles.css.ts
the production build works correctly.When the styles are not applied I am seeing the correct classnames in the mark up and the correct css generated in
./.next/static/css/*
however the css files are not being loaded.I made the page and layout client components to avoid any possible issues with Next's server components.
Dev Build:
Production Build:
Reproduction
https://github.com/zackshackleton/sprinkles-nextjs13
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: