Add flag to resolve content relative to the config file
This commit is contained in:
parent
4bff7654f5
commit
91ddcedb37
4 changed files with 11 additions and 3 deletions
|
|
@ -15,6 +15,7 @@ let featureFlags = {
|
|||
'optimizeUniversalDefaults',
|
||||
'matchVariant',
|
||||
// 'variantGrouping',
|
||||
'resolveContentRelativeToConfig',
|
||||
'resolveConfigRelativeToInput',
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -997,6 +997,8 @@ export function getContext(
|
|||
|
||||
let context = createContext(tailwindConfig, [], root)
|
||||
|
||||
Object.assign(context, { userConfigPath })
|
||||
|
||||
trackModified([...contextDependencies], getFileModifiedMap(context))
|
||||
|
||||
// ---
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ export default function setupTrackingContext(configOrPath) {
|
|||
|
||||
// Add template paths as postcss dependencies.
|
||||
for (let fileOrGlob of candidateFiles) {
|
||||
for (let dependency of parseDependency(fileOrGlob)) {
|
||||
for (let dependency of parseDependency(context, fileOrGlob)) {
|
||||
registerDependency(dependency)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function toDependency(pathDesc) {
|
|||
}
|
||||
}
|
||||
|
||||
export default function parseDependency(normalizedFileOrGlob) {
|
||||
export default function parseDependency(context, normalizedFileOrGlob) {
|
||||
if (normalizedFileOrGlob.startsWith('!')) {
|
||||
return []
|
||||
}
|
||||
|
|
@ -66,9 +66,14 @@ export default function parseDependency(normalizedFileOrGlob) {
|
|||
paths.push({ base: normalizedFileOrGlob, glob: null })
|
||||
}
|
||||
|
||||
// Resolve base paths relative to the config file or current working directory
|
||||
let resolveFrom = flagEnabled(context.tailwindConfig, 'resolveContentRelativeToConfig')
|
||||
? [context.userConfigPath ?? process.cwd()]
|
||||
: [process.cwd()]
|
||||
|
||||
paths = paths.map((pathDesc) =>
|
||||
Object.assign(pathDesc, {
|
||||
base: path.resolve(pathDesc.base),
|
||||
base: path.resolve(...resolveFrom, pathDesc.base),
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue