Skip to content

Commit e8b7b3d

Browse files
RobinMalfaitphilipp-spiess
authored andcommitted
contentPaths accept a Vec<GlobEntry>
1 parent 903341d commit e8b7b3d

File tree

1 file changed

+16
-5
lines changed
  • packages/@tailwindcss-cli/src/commands/build

1 file changed

+16
-5
lines changed

packages/@tailwindcss-cli/src/commands/build/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,13 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
126126
}
127127

128128
let inputFile = args['--input'] && args['--input'] !== '-' ? args['--input'] : process.cwd()
129-
130-
let basePath = path.dirname(path.resolve(inputFile))
129+
let inputFilePath = path.dirname(path.resolve(inputFile))
131130

132131
function compile(css: string) {
133132
return tailwindcss.compile(css, {
134133
loadPlugin: (pluginPath) => {
135134
if (pluginPath[0] === '.') {
136-
return require(path.resolve(basePath, pluginPath))
135+
return require(path.resolve(inputFilePath, pluginPath))
137136
}
138137

139138
return require(pluginPath)
@@ -143,7 +142,13 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
143142

144143
// Compile the input
145144
let compiler = compile(input)
146-
let scanDirResult = scanDir({ base, contentPaths: compiler.globs })
145+
let scanDirResult = scanDir({
146+
base, // Root directory, mainly used for auto content detection
147+
contentPaths: compiler.globs.map((glob) => ({
148+
base: inputFilePath, // Globs are relative to the input.css file
149+
glob,
150+
})),
151+
})
147152

148153
// Watch for changes
149154
if (args['--watch']) {
@@ -202,7 +207,13 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
202207
compiler = compile(input)
203208

204209
// Re-scan the directory to get the new `candidates`
205-
scanDirResult = scanDir({ base, contentPaths: compiler.globs })
210+
scanDirResult = scanDir({
211+
base, // Root directory, mainly used for auto content detection
212+
contentPaths: compiler.globs.map((glob) => ({
213+
base: inputFilePath, // Globs are relative to the input.css file
214+
glob,
215+
})),
216+
})
206217

207218
// Setup new watchers
208219
cleanupWatchers = await createWatchers(scanDirResult.globs, handle)

0 commit comments

Comments
 (0)