How to use tailwindcss/jit library with create-react-app?

Viewed 2626

I followed this installation step to configure tailwindcss in create-react-app. It works, but after adding tailwindcss/jit, app is not working. I think that it happens because create-react-app doesn't support PostCSS 8, but it seems that tailwindcss/jit requires PostCSS 8.

Any idea?

2 Answers

jit is now included in the v2.1.0 build so you just need to upgrade. Easiest way is to just uninstall the dependencies and reinstall.

It's working in my app...but not all classes are being output so that will be something I need to figure out.

npm uninstall tailwindcss
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat @tailwindcss/postcss7-compat

at the minute docs here https://tailwindcss.com/docs/guides/create-react-app are for tailwind stable (2.0.3) and requesting you to use postcss 7 as stable release does not support postcss 8.

tailwindcss jit has postcss 8 support, so steps relating to postcss 7 (and craco) are redundant for jit version.

create-react-app supports postcss 8.

Related