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

[JIT] prefix as a function breaks some classes #5765

Closed
quentinlagache opened this issue Oct 12, 2021 · 5 comments · Fixed by #5829
Closed

[JIT] prefix as a function breaks some classes #5765

quentinlagache opened this issue Oct 12, 2021 · 5 comments · Fixed by #5829

Comments

@quentinlagache
Copy link

quentinlagache commented Oct 12, 2021

What version of Tailwind CSS are you using?
2.2.15

Reproduction URL
https://play.tailwindcss.com/GlwsJggWJP?file=config

Describe your issue
When using prefix as a function to apply prefix only on some classes, it seems that classes with one character base name like m-2, p-5, w-full and negative ones like -rotate-6 are not generated.

Add prefix (selector) { return ''; } to tailwind config is breaking the output.

expected

current

@quentinlagache quentinlagache changed the title [JIT] prefix as a function prevent generation of 1 character base name classes [JIT] prefix as a function prevent generation of some classes Oct 12, 2021
@Soviut
Copy link
Contributor

Soviut commented Oct 17, 2021

I can't reproduce. Your example seems to work for the classes you mentioned.

I tried the following

  prefix(selector) {
    console.log(selector)
    return ''
  },

And this printed out all the classes, including the ones you mentioned.

image

including negatives

image

@quentinlagache
Copy link
Author

quentinlagache commented Oct 17, 2021

Thanks for your input and interest regarding this issue @Soviut.

The issue is shown on the Tailwind Play link attached so I'm confident it's not only an issue with my codebase (I'm relying on @tailwindcss/postcss7-compat)
You can highlight it by applying/removing the following code from the config file:

prefix (selector) { return ''; },

@Soviut
Copy link
Contributor

Soviut commented Oct 17, 2021

@quentinlagache Ah, I misunderstood. The following is NOT the desired output. I was focusing on the classes in the selector too much.

image

@quentinlagache quentinlagache changed the title [JIT] prefix as a function prevent generation of some classes [JIT] prefix as a function breaks some classes Oct 19, 2021
@RobinMalfait
Copy link
Contributor

Hey! Thank you for your bug report!
Much appreciated! 🙏

I've been looking into this and wrote a more in-depth explanation here: #5829
What I would recommend you to do is to use the prefix as a string instead of a function.

@quentinlagache
Copy link
Author

quentinlagache commented Oct 19, 2021

Hey @RobinMalfait !
I dug into your explanation and really appreciate how far you push it and all details you provide to explain the issue and how you will sort this in the JIT world. It's real insights into Tailwind development and a very instructive reading 🙌

In the end, I get a better sense of why prefix as a function is more of a hacky solution in this regard and the lack of consistency it brings to outputted classes.

In my case I will handle it outside of tailwind to keep prefix free tailwind classes.

Thanks for your awesome work 🙏

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

Successfully merging a pull request may close this issue.

3 participants