Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions packages/@tailwindcss-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,31 @@ class Root {

DEBUG && I.start('Setup compiler')
let addBuildDependenciesPromises: Promise<void>[] = []
this.compiler = await compile(content, {
from: this.enableSourceMaps ? this.id : undefined,
base: inputBase,
shouldRewriteUrls: true,
onDependency: (path) => {
addWatchFile(path)
addBuildDependenciesPromises.push(this.addBuildDependency(path))
},
try {
this.compiler = await compile(content, {
from: this.enableSourceMaps ? this.id : undefined,
base: inputBase,
shouldRewriteUrls: true,
onDependency: (path) => {
addWatchFile(path)
addBuildDependenciesPromises.push(this.addBuildDependency(path))
},

customCssResolver: this.customCssResolver,
customJsResolver: this.customJsResolver,
})
customCssResolver: this.customCssResolver,
customJsResolver: this.customJsResolver,
})
} catch (error) {
// If a dependency file was deleted during HMR (e.g. an SVG asset),
// the compile step will fail with ENOENT. Handle this gracefully by
// invalidating the compiler so the next rebuild picks up the change.
if (error instanceof Error && 'code' in error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
DEBUG && I.end('Setup compiler')
this.compiler = undefined
this.scanner = undefined
return false
}
throw error
}
await Promise.all(addBuildDependenciesPromises)
DEBUG && I.end('Setup compiler')

Expand Down