diff options
author | 2022-11-01 10:50:53 -0400 | |
---|---|---|
committer | 2022-11-01 10:50:53 -0400 | |
commit | bb6e8800094dc59841eb3b345fcb8baca9e17ce9 (patch) | |
tree | adddde5a39005b3925cb73b194030bade98ea899 | |
parent | 63a3282f8112ef88fbc537bb93bc1e31eb65ab54 (diff) | |
download | astro-bb6e8800094dc59841eb3b345fcb8baca9e17ce9.tar.gz astro-bb6e8800094dc59841eb3b345fcb8baca9e17ce9.tar.zst astro-bb6e8800094dc59841eb3b345fcb8baca9e17ce9.zip |
Prevent tailwind config errors from crashing dev server (#5270)
* Prevent tailwind config errors from crashing dev server
* Adding a changeset
* Fix wrong type
-rw-r--r-- | .changeset/long-turtles-run.md | 5 | ||||
-rw-r--r-- | packages/integrations/tailwind/src/index.ts | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/.changeset/long-turtles-run.md b/.changeset/long-turtles-run.md new file mode 100644 index 000000000..599c3c99a --- /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 bc4d820d5..fb75e34fe 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<Record<any, any>> | undefined; try { + result = await load('tailwind', { + mustExist: false, + cwd: resolvedRoot, + filePath: tempConfigPath, + }); + await fs.unlink(tempConfigPath); } catch { /** file already removed */ |