Skip to content

Commit 9e53811

Browse files
committed
Resolve auto-loaded v3 configs relative to the file being processed
1 parent 7604082 commit 9e53811

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
7171
// For the same reasons as the v4 stylesheet, it's important that the config
7272
// file be resolved relative to the file it's configured in.
7373
if (!stylesheet && !mod?.__unstable__loadDesignSystem) {
74-
let jsConfig = resolveJsConfigPath(options, configDir)
74+
let jsConfig = resolveJsConfigPath(options, configDir, inputDir)
7575
if (jsConfig) {
7676
return pathToApiMap.remember(`${pkgDir}:${jsConfig}`, () => loadV3(pkgDir, jsConfig))
7777
}
@@ -141,18 +141,18 @@ async function resolveTailwindPath(options: ParserOptions, baseDir: string): Pro
141141
}
142142

143143
let configPathCache = new Map<string, string | null>()
144-
function resolveJsConfigPath(options: ParserOptions, configDir: string): string | null {
144+
function resolveJsConfigPath(options: ParserOptions, configDir: string, inputDir: string): string | null {
145145
if (options.tailwindConfig) {
146146
if (options.tailwindConfig.endsWith('.css')) return null
147147

148148
return path.resolve(configDir, options.tailwindConfig)
149149
}
150150

151-
let configPath: string | null | undefined = configPathCache.get(configDir)
151+
let configPath: string | null | undefined = configPathCache.get(inputDir)
152152

153153
if (configPath === undefined) {
154154
try {
155-
let foundPath = escalade(configDir, (_, names) => {
155+
let foundPath = escalade(inputDir, (_, names) => {
156156
if (names.includes('tailwind.config.js')) return 'tailwind.config.js'
157157
if (names.includes('tailwind.config.cjs')) return 'tailwind.config.cjs'
158158
if (names.includes('tailwind.config.mjs')) return 'tailwind.config.mjs'
@@ -163,7 +163,7 @@ function resolveJsConfigPath(options: ParserOptions, configDir: string): string
163163
} catch {}
164164

165165
configPath ??= null
166-
configPathCache.set(configDir, configPath)
166+
configPathCache.set(inputDir, configPath)
167167
}
168168

169169
return configPath

0 commit comments

Comments
 (0)