Prevent tailwind config errors from crashing dev server (#5270)

* Prevent tailwind config errors from crashing dev server

* Adding a changeset

* Fix wrong type
This commit is contained in:
Matthew Phillips 2022-11-01 10:50:53 -04:00 committed by GitHub
parent 63a3282f81
commit bb6e880009
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/tailwind': patch
---
Prevent errors during HMR from crashing dev server

View file

@ -40,13 +40,14 @@ async function getUserConfig(root: URL, configPath?: string, isRestart = false)
const tempConfigPath = path.join(dir, `.temp.${Date.now()}.${base}`);
await fs.copyFile(resolvedConfigPath, tempConfigPath);
const result = await load('tailwind', {
let result: load.Config<Record<any, any>> | undefined;
try {
result = await load('tailwind', {
mustExist: false,
cwd: resolvedRoot,
filePath: tempConfigPath,
});
try {
await fs.unlink(tempConfigPath);
} catch {
/** file already removed */