Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

JIT does not work when prefix callback is specified #159

Closed
signor-pedro opened this issue Mar 26, 2021 · 3 comments · Fixed by #177
Closed

JIT does not work when prefix callback is specified #159

signor-pedro opened this issue Mar 26, 2021 · 3 comments · Fixed by #177

Comments

@signor-pedro
Copy link

What version of @tailwindcss/jit are you using?

0.1.10

What version of Node.js are you using?

15.9.0

What browser are you using?

all of them

What operating system are you using?

macOS

Reproduction repository

https://github.com/signor-pedro/tailwind-repro

Commenting this out makes JIT work

prefix(selector) {
    if (['.align-bottom', '.ml-1'].includes(selector)) {
      return 'tw-';
    }

    return '';
  },
@signor-pedro
Copy link
Author

signor-pedro commented Mar 26, 2021

Just to clarify - adding a prefix callback does not break only the should-be-prefixed classes.

When I specify the prefix callback, the entire tailwind fails to generate anything (even classes such as bg-indigo-200 which are not manipulated with in any way in the callback).

You may run the example repo with NODE_ENV="production" TAILWIND_MODE="build" ./node_modules/.bin/encore production

Thank you for any help on this :)

@adamwathan
Copy link
Member

Added in v0.1.17! There's one limitation which is that you can't do exact matches against dynamically generated utilities, like ml-5. Instead, you'll just want to match against the prefix of the utility, so like this:

prefix(selector) {
  if (['.align-bottom', '.ml'].some(utility => selector.startsWith(utility))) {
    return 'tw-';
  }

  return '';
},

Hopefully this is good enough for the use cases people have for this feature in the real world 👍🏻

@signor-pedro
Copy link
Author

Thank you very much, the solution is good enough, only needed to override bootstrap-conflicting classes (which are all the ml-s etc. anyways).

Made my day!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants