Open
Description
What version of Tailwind CSS are you using?
v4.1.6
What build tool (or framework if it abstracts the build tool) are you using?
Next.js 15.3.2
What version of Node.js are you using?
v22.11.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
https://github.com/Multiply/next.js-tailwind-conic-bug
(based on npx create-next-app@latest
for the initial commit)
Describe your issue
In next.js production builds (npm run build
-> npm run start
) bg-conic
's background-image
does not work.
It works fine in development builds npm run dev
.
My initial thoughts would be that it's a @layer
issue, but I haven't played too much with it yet, to really debug it further.
Activity
wongjn commentedon May 12, 2025
Debugged the difference with
@tailwindcss/cli --minify
. The key difference stopping it from working is:It seems like some extra CSS minifier strips the percentage sign from the above
@property
value, causing the gradient to stop working.You can workaround this by adding the class name
from-0%
but probably not ideal.Multiply commentedon May 12, 2025
I noticed this initially, and assumed 0 was an accepted value for
syntax: "<length-percentage>";
It seems like it does this for other values as well.
RobinMalfait commentedon May 12, 2025
Hey!
This is happening because of a minifier used in Next.js. As a workaround, you could add this workaround to your
next.config.js
file:Or use ESM / TypeScript, the important part is the webpack config to remove the CSS minifier.
Multiply commentedon May 12, 2025
Are there any tickets tracking this issue that you know of, @RobinMalfait?
RobinMalfait commentedon May 12, 2025
@Multiply not yet, I have to create a minimal reproduction and open an issue, but wanted to give you a workaround in the meantime.
Multiply commentedon May 12, 2025
Following some breadcrumbs, this might have fixed it?
cssnano/cssnano#1695
Edit:
Seems like nextjs@canary is using cssnano-preset-default@7.0.6 that doesn't contain the above PR, so maybe upgrading to 7.0.7 could do something.
RobinMalfait commentedon May 12, 2025
That might fix it, but I also think that Next.js is bundling the dependency instead of relying on it as an actual dependency. They also use
cssnano-simple
: https://github.com/vercel/next.js/tree/canary/packages/next/src/bundles/cssnano-simpleMultiply commentedon May 12, 2025
Yes, that's where I got the above package from, as they include that in there.
Multiply commentedon May 12, 2025
As a follow-up, I'm confident the PR I referenced earlier does not fix the underlying issue. It's only about
<percentage>
and quotes around it, it doesn't affect<length-percentage>
. (See my comment here: cssnano/cssnano#1695 (comment))I'd assume if we just add one more condition there, it'll be solved.
Edit: I've added a PR to solve it here: cssnano/cssnano#1702
next build
vercel/next.js#79149RobinMalfait commentedon May 13, 2025
Opened an upstream issue with a reproduction:
next build
vercel/next.js#79149sumansuhag commentedon May 13, 2025
SilvioDoMine commentedon Jun 7, 2025
This issue is happening on Nuxt.js production builds as well
IsmeetKachhap007 commentedon Jun 19, 2025
Workarounds and Solutions Disable CSS Minification in Next.js You can disable the problematic CSS minifier in your Next.js production build by modifying your next.config.js file:-
// next.config.js
const nextConfig = {
webpack(config) {
// Remove the CSS minifier (CssMinimizerPlugin) that breaks conic gradients
config.optimization.minimizer = config.optimization.minimizer.filter((fn) => {
return !fn.toString().includes("CssMinimizerPlugin");
});
return config;
},
};
module.exports = nextConfig;
This disables CSS minification, which prevents the percentage sign from being stripped and allows bg-conic to work as expected in production.
This might work.
devmuhnnad commentedon Jun 24, 2025
Manually patch the output CSS file (post-build hook)
If you want to keep minification but fix the bug, you can patch the final output file via a custom Node script after build.
scripts/patch-css.js
Run this after build:
✅ This ensures the CSS is fixed after all minification.