@@ -29,12 +29,16 @@ let prettierConfigCache = expiringMap<string, string | null>(10_000)
29
29
export async function getTailwindConfig (
30
30
options : ParserOptions ,
31
31
) : Promise < ContextContainer > {
32
+ let pkgName = options . tailwindPackageName ?? 'tailwindcss'
33
+
32
34
let key = [
33
35
options . filepath ,
34
36
options . tailwindStylesheet ?? '' ,
35
37
options . tailwindEntryPoint ?? '' ,
36
38
options . tailwindConfig ?? '' ,
39
+ pkgName ,
37
40
] . join ( ':' )
41
+
38
42
let baseDir = await getBaseDir ( options )
39
43
40
44
// Map the source file to it's associated Tailwind config file
@@ -58,7 +62,12 @@ export async function getTailwindConfig(
58
62
}
59
63
60
64
// By this point we know we need to load the Tailwind config file
61
- let result = await loadTailwindConfig ( baseDir , configPath , entryPoint )
65
+ let result = await loadTailwindConfig (
66
+ baseDir ,
67
+ pkgName ,
68
+ configPath ,
69
+ entryPoint ,
70
+ )
62
71
63
72
pathToContextMap . set ( contextKey , result )
64
73
@@ -100,6 +109,7 @@ async function getBaseDir(options: ParserOptions): Promise<string> {
100
109
101
110
async function loadTailwindConfig (
102
111
baseDir : string ,
112
+ pkgName : string ,
103
113
tailwindConfigPath : string | null ,
104
114
entryPoint : string | null ,
105
115
) : Promise < ContextContainer > {
@@ -110,11 +120,11 @@ async function loadTailwindConfig(
110
120
let tailwindConfig : RequiredConfig = { content : [ ] }
111
121
112
122
try {
113
- let pkgFile = resolveJsFrom ( baseDir , 'tailwindcss /package.json' )
123
+ let pkgFile = resolveJsFrom ( baseDir , ` ${ pkgName } /package.json` )
114
124
let pkgDir = path . dirname ( pkgFile )
115
125
116
126
try {
117
- let v4 = await loadV4 ( baseDir , pkgDir , entryPoint )
127
+ let v4 = await loadV4 ( baseDir , pkgDir , pkgName , entryPoint )
118
128
if ( v4 ) {
119
129
return v4
120
130
}
@@ -197,10 +207,11 @@ function createLoader<T>({
197
207
async function loadV4 (
198
208
baseDir : string ,
199
209
pkgDir : string ,
210
+ pkgName : string ,
200
211
entryPoint : string | null ,
201
212
) {
202
213
// Import Tailwind — if this is v4 it'll have APIs we can use directly
203
- let pkgPath = resolveJsFrom ( baseDir , 'tailwindcss' )
214
+ let pkgPath = resolveJsFrom ( baseDir , pkgName )
204
215
205
216
let tw = await import ( pathToFileURL ( pkgPath ) . toString ( ) )
206
217
0 commit comments