@@ -29,12 +29,16 @@ let prettierConfigCache = expiringMap<string, string | null>(10_000)
2929export async function getTailwindConfig (
3030 options : ParserOptions ,
3131) : Promise < ContextContainer > {
32+ let pkgName = options . tailwindPackageName ?? 'tailwindcss'
33+
3234 let key = [
3335 options . filepath ,
3436 options . tailwindStylesheet ?? '' ,
3537 options . tailwindEntryPoint ?? '' ,
3638 options . tailwindConfig ?? '' ,
39+ pkgName ,
3740 ] . join ( ':' )
41+
3842 let baseDir = await getBaseDir ( options )
3943
4044 // Map the source file to it's associated Tailwind config file
@@ -58,7 +62,12 @@ export async function getTailwindConfig(
5862 }
5963
6064 // 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+ )
6271
6372 pathToContextMap . set ( contextKey , result )
6473
@@ -100,6 +109,7 @@ async function getBaseDir(options: ParserOptions): Promise<string> {
100109
101110async function loadTailwindConfig (
102111 baseDir : string ,
112+ pkgName : string ,
103113 tailwindConfigPath : string | null ,
104114 entryPoint : string | null ,
105115) : Promise < ContextContainer > {
@@ -110,11 +120,11 @@ async function loadTailwindConfig(
110120 let tailwindConfig : RequiredConfig = { content : [ ] }
111121
112122 try {
113- let pkgFile = resolveJsFrom ( baseDir , 'tailwindcss /package.json' )
123+ let pkgFile = resolveJsFrom ( baseDir , ` ${ pkgName } /package.json` )
114124 let pkgDir = path . dirname ( pkgFile )
115125
116126 try {
117- let v4 = await loadV4 ( baseDir , pkgDir , entryPoint )
127+ let v4 = await loadV4 ( baseDir , pkgDir , pkgName , entryPoint )
118128 if ( v4 ) {
119129 return v4
120130 }
@@ -197,10 +207,11 @@ function createLoader<T>({
197207async function loadV4 (
198208 baseDir : string ,
199209 pkgDir : string ,
210+ pkgName : string ,
200211 entryPoint : string | null ,
201212) {
202213 // 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 )
204215
205216 let tw = await import ( pathToFileURL ( pkgPath ) . toString ( ) )
206217
0 commit comments