diff --git a/.changeset/long-turtles-run.md b/.changeset/long-turtles-run.md new file mode 100644 index 0000000000..599c3c99a1 --- /dev/null +++ b/.changeset/long-turtles-run.md @@ -0,0 +1,5 @@ +--- +'@astrojs/tailwind': patch +--- + +Prevent errors during HMR from crashing dev server diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts index bc4d820d5b..fb75e34fee 100644 --- a/packages/integrations/tailwind/src/index.ts +++ b/packages/integrations/tailwind/src/index.ts @@ -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', { - mustExist: false, - cwd: resolvedRoot, - filePath: tempConfigPath, - }); - + let result: load.Config> | undefined; try { + result = await load('tailwind', { + mustExist: false, + cwd: resolvedRoot, + filePath: tempConfigPath, + }); + await fs.unlink(tempConfigPath); } catch { /** file already removed */