Skip to content

TailwindCSS v4 supported? #58

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

Closed
codyng opened this issue Feb 12, 2025 · 8 comments
Closed

TailwindCSS v4 supported? #58

codyng opened this issue Feb 12, 2025 · 8 comments
Assignees
Labels
enhancement New feature or request priority

Comments

@codyng
Copy link

codyng commented Feb 12, 2025

Hi, may I know if this great library supports TailwindCSS v4?

When I executed it on my web project using TailwindCSS v4 it threw below errors:

<local-project-root-path>/node_modules/css/lib/parse/index.js:62
    var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
              ^

Error: undefined:1:79: missing '}'
    at error (<local-project-root-path>/node_modules/css/lib/parse/index.js:62:15)
    at declarations (<local-project-root-path>/node_modules/css/lib/parse/index.js:260:26)
    at rule (<local-project-root-path>/node_modules/css/lib/parse/index.js:561:21)
    at rules (<local-project-root-path>/node_modules/css/lib/parse/index.js:118:70)
    at stylesheet (<local-project-root-path>/node_modules/css/lib/parse/index.js:81:21)
    at module.exports [as parse] (<local-project-root-path>/node_modules/css/lib/parse/index.js:565:20)
    at <local-project-root-path>/node_modules/next-css-obfuscator/dist/handlers/css.js:98:38
    at Array.forEach (<anonymous>)
    at createSelectorConversionJson (<local-project-root-path>/node_modules/next-css-obfuscator/dist/handlers/css.js:96:14)
    at obfuscate (<local-project-root-path>/node_modules/next-css-obfuscator/dist/index.js:26:44) {
  reason: "missing '}'",
  filename: undefined,
  line: 1,
  column: 79,
  source: ':root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Col

The css-obfuscator folder was created but it was empty.

The contentIgnoreRegexes in next-css-obfuscator.config.js is here. I am not sure it's matter.

	contentIgnoreRegexes: [
		/\.jsxs\)\("\w+"/g,	// default
		/id="[\w\-]+"/g,	// ignore all id="xxx" for HTML
	],

But it's fine if I used TailwindCSS v3.

Cheers,
Cody

@codyng
Copy link
Author

codyng commented Feb 12, 2025

I found that TailwindCSSd 4 uses @layer to wrap the minified styles, which causes the compilation to fail.
The last css content started with

/*! tailwindcss v4.0.6 | MIT License | https://tailwindcss.com */@layer theme{:root,:host{--font-sans:ui
...
...

In my dist folder that is succeeded in TailwindCSS v3, I tried to place a css file with below content:

@layer theme {
	.hello {
		color: red;
	}
}

Indeed it threw the same error:

...
  reason: "missing '}'",
  filename: undefined,
  line: 2,
  column: 2,
  source: '.hello {\n\t\tcolor: red;\n\t}\n}'
}

@codyng
Copy link
Author

codyng commented Feb 12, 2025

It looks like the css library issue.

Will you consider to use css-tools? It seems that it supports @layer rule and many others.

@soranoo
Copy link
Owner

soranoo commented Feb 12, 2025

Good question! I haven't touched v4 at all 😢 . I will take a look at it and see if I can come up with a better solution (Im looking at Lightning CSS)

@soranoo soranoo added enhancement New feature or request priority labels Feb 12, 2025
@soranoo soranoo self-assigned this Feb 16, 2025
soranoo added a commit that referenced this issue Mar 3, 2025
@andr3i1010
Copy link

any updates?

@soranoo
Copy link
Owner

soranoo commented May 30, 2025

A new CSS transformation engine is complete, but it has not yet been fully integrated into this package (currently beta, ps. features are subject to change without notice). I am also looking for a complex tailwind 4 project for testing purposes. Let me know if you got one.

@andr3i1010
Copy link

andr3i1010 commented May 30, 2025

try my repo PolarLearn, it uses shadcn and alot of tw 4 classes, please note that the repo and project itself is dutch so you might need a translator

@soranoo soranoo mentioned this issue May 31, 2025
@soranoo
Copy link
Owner

soranoo commented May 31, 2025

v.3.0.0 now supports TailwindCSS 4

Migrate from version 2.x to 3.x

ps. I don't see any problems with tw4 so far, except for the issue related to the JS part, which can be fixed by fine-tuning the config(very likely). Thank you for your resources @andr3i1010

@soranoo soranoo closed this as completed May 31, 2025
@andr3i1010
Copy link

No problem at all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority
Projects
None yet
Development

No branches or pull requests

3 participants