How to use NPM package component with Tailwind in JIT mode? #5410
Unanswered
gilsonnunesfilho
asked this question in
Help
Replies: 1 comment
-
|
You should be able to solve that by specifying the path to your components inside const { join } = require('path')
const { preset } = require('@scope/package-name/tailwind.config')
const mapDirs = (i) => join(__dirname, i)
const contentDirs = [
'/components/**/*.{js,jsx,ts,tsx,vue}',
'/layouts/**/*.{js,jsx,ts,tsx,vue}',
'/middleware/**/*.{js,jsx,ts,tsx,vue}',
'/mixins/**/*.{js,jsx,ts,tsx,vue}',
'/pages/**/*.{js,jsx,ts,tsx,vue}',
'/plugins/**/*.{js,jsx,ts,tsx,vue}',
'/formulate.config.js',
'/nuxt.config.js',
'/tailwind.config.js',
]
module.exports = {
mode: 'jit',
presets: [preset],
purge: {
enable: true,
content: [
...contentDirs.map(mapDirs),
...contentDirs.map((i) => `/node_modules/@koa-health/common${i}`).map(mapDirs),
],
},
} |
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.
-
The idea
Let me try to explain a little bit more. I was trying to create external component library that uses Tailwind under the hood wrapped in styled-components, like bellow:
This library was supposed to be our design system, and should be used on other applications, like so:
I'd like to be able to use it like this as baseline components, and extend it when wanted:
The problem
When I published the components to NPM, and imported them on my app, the Tailwind's JIT mode couldn't pick up the CSS classes from my component, so I was unable to keep developing the app.
The temporary solution was to copy all the code as a local copy, but that's awkward having to copy/paste instead of import from the package.
Any suggestions?
Thank you very much if you read through down here.
Beta Was this translation helpful? Give feedback.
All reactions