Skip to content

Commit

Permalink
Prevent tailwind config errors from crashing dev server (#5270)
Browse files Browse the repository at this point in the history
* Prevent tailwind config errors from crashing dev server

* Adding a changeset

* Fix wrong type
  • Loading branch information
matthewp authored Nov 1, 2022
1 parent 63a3282 commit bb6e880
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-turtles-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/tailwind': patch
---

Prevent errors during HMR from crashing dev server
13 changes: 7 additions & 6 deletions packages/integrations/tailwind/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit bb6e880

Please sign in to comment.