Skip to content
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

postcss-import module breaks content & safelist when using TailwindCLI #8153

Closed
ghost opened this issue Apr 19, 2022 · 5 comments
Closed

postcss-import module breaks content & safelist when using TailwindCLI #8153

ghost opened this issue Apr 19, 2022 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2022

What version of Tailwind CSS are you using?
Tested from 3.0.0 to 3.0.24

What build tool (or framework if it abstracts the build tool) are you using?
TailwindCSS CLI from 3.0.0 to 3.0.24

What version of Node.js are you using?
v12.13.0

What browser are you using?
Chrome

What operating system are you using?
Linux (server & compilation side)

Reproduction repository:

Assets URL (pastebin urls)

Command i use to compile from build_1 folder (see below folder structure):
/path/from/root/tailwind-v3/tailwindcss -i tailwind.css -o tailwind.min.css --postcss

My folder structure is like so:

tailwind-v3
├── tailwindcss     # tailwindcss is the standalone linux bin of 3.0.24 you released
├── tmp
│   ├── build
│   ├── ──  build_1                     # the folder where i init the CLI command
│   ├── ── ── tailwind.css              # it's my input tailwind.css file
│   ├── ── ── tailwind.config.js
│   ├── ── ── postcss.config.js
│   ├── ── ── safelist.txt              # the file which contains all the potential classes i want to generate
└── ...

Describe your issue

My safelist.txt is used in 'content': ['./safelist.txt'], in my tailwind.config.js
Also tried to add all words present in my safelist.txt directly into safelist as your doc says in my tailwind.config.js but it never generates my classes.
For example, the .flex class is not present in my final generated tailwind.min.css file.

Output i get from CLI is: Done in 2328ms.
It does generate a tailwind.min.css but only with the content in my tailwind.css file.
So it seems to find & use my safelist.txt in content since i have no "Warn, no content defined" message but doesn't generate classes.

@ghost ghost changed the title "content" & "safelist" seems to be ignored in my tailwind.config.js (standalone) "content" & "safelist" classes seems to be ignored in my tailwind.config.js (standalone) Apr 19, 2022
@adamwathan
Copy link
Member

Hey! Do you mind providing an actual reproduction repository we can clone that demonstrates the issue? Trying to create a reproduction ourselves from the information in an issue drastically increases the amount of time it takes for us to provide a solution and if we have do that for every issue it’s impossible for us to keep up.

@ghost
Copy link
Author

ghost commented Apr 19, 2022

Hey @adamwathan
Thanks for the reactivity!

You're right, i even realised i forgot some parts, here you go :) (I added a readme with steps)
https://github.com/Pilot-in/tailwind-issue-8153

@ghost ghost changed the title "content" & "safelist" classes seems to be ignored in my tailwind.config.js (standalone) "content" & "safelist" classes seems to be ignored in my tailwind.config.js Apr 20, 2022
@ghost
Copy link
Author

ghost commented Apr 20, 2022

I did more tests & it seems not only related to standalone, CLI has the same issue running npx tailwindcss -i tailwind.css -o tailwind.min.css --postcss in the reproduction repository subfolder build_1

@ghost
Copy link
Author

ghost commented Apr 20, 2022

After further testings, i found that postcss-import in postcss.config.js seems to be the module breaking content & safelist features (i don't know why tho')

@ghost ghost changed the title "content" & "safelist" classes seems to be ignored in my tailwind.config.js postcss-import module breaks content & safelist Apr 20, 2022
@ghost ghost changed the title postcss-import module breaks content & safelist postcss-import module breaks content & safelist when using TailwindCLI Apr 20, 2022
@bradlc
Copy link
Contributor

bradlc commented Apr 25, 2022

Hey @damien-pilot-in. postcss-import adheres to the CSS spec and disallows @import statements anywhere except at the very top of a file. Because your tailwindcss/components and tailwindcss/utilities imports are not at the top of your CSS file they are not being pulled in. Check out the Tailwind CSS documentation for more information and workarounds: https://tailwindcss.com/docs/using-with-preprocessors#build-time-imports

In your specific case, since you only have one CSS file one option would be to replace the tailwindcss imports with @tailwind directives:

- @import "tailwindcss/base";
+ @tailwind base;

...

- @import "tailwindcss/components";
+ @tailwind components;

...

- @import "tailwindcss/utilities";
+ @tailwind utilities;

I hope that helps!

@bradlc bradlc closed this as completed Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants