v4 Functions and Directives not working with package imported styles #17307
Replies: 1 comment
-
I figured it out. I was double importing |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on building a component library package, similar to how DaisyUI is but I'm running into an issue when I import that into another package. I'm currently doing this in a monorepo setup, but I'd like to eventually publish these separate packages to NPM for use in other projects.
Here's an example setup:
@mycompany/tokens
package that exposes multiple "themes" as separate CSS files to use so they can be imported into each tailwind instance to apply styling. These mimic the same setup as Tailwind's default theme.@mycompany/styles
exposes astyles.css
file with some testing functions and directives in it:However, I'm getting errors such as:
The --spacing(…) function requires that the
--spacingtheme variable exists, but it was not found.
Cannot apply unknown utility class: text-white
However, if I copy/paste the contents of the two imports shown above, put them in files local to the project CSS such as
./tokens.css
and./styles.css
(exact same content as imported from the other packages in the monorepo), they render no problem.The core of the issue seems to be that TW doesn't seem to extend it's functions and directives to module imports. It will import the CSS just fine from a module, but if I use any special
@apply
rules or functions such as--spacing(4)
, it will error. If I remove functions/directives like this from the module css, the classes come through and still import correctly.How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions