Skip to content

Commit 31f8f4b

Browse files
Vite: Work around crash when .svg file contains # or ?
1 parent 50cce50 commit 31f8f4b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/@tailwindcss-vite/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,20 @@ class Root {
218218
// not considered a Tailwind root. When this happened, the root can be GCed.
219219
public async generate(
220220
content: string,
221-
addWatchFile: (file: string) => void,
221+
_addWatchFile: (file: string) => void,
222222
I: Instrumentation,
223223
): Promise<string | false> {
224+
function addWatchFile(file: string) {
225+
// Scanning `.svg` file containing a `#` or `?` in the path will
226+
// crash Vite. We work around this for now by ignoring updates to them.
227+
//
228+
// https://github.com/tailwindlabs/tailwindcss/issues/16877
229+
if (/[\#\?].*\.svg$/.test(file)) {
230+
return
231+
}
232+
_addWatchFile(file)
233+
}
234+
224235
let requiresBuildPromise = this.requiresBuild()
225236
let inputPath = idToPath(this.id)
226237
let inputBase = path.dirname(path.resolve(inputPath))

0 commit comments

Comments
 (0)