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:
parent
63a3282f81
commit
bb6e880009
2 changed files with 12 additions and 6 deletions
5
.changeset/long-turtles-run.md
Normal file
5
.changeset/long-turtles-run.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/tailwind': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent errors during HMR from crashing dev server
|
|
@ -40,13 +40,14 @@ async function getUserConfig(root: URL, configPath?: string, isRestart = false)
|
||||||
const tempConfigPath = path.join(dir, `.temp.${Date.now()}.${base}`);
|
const tempConfigPath = path.join(dir, `.temp.${Date.now()}.${base}`);
|
||||||
await fs.copyFile(resolvedConfigPath, tempConfigPath);
|
await fs.copyFile(resolvedConfigPath, tempConfigPath);
|
||||||
|
|
||||||
const result = await load('tailwind', {
|
let result: load.Config<Record<any, any>> | undefined;
|
||||||
mustExist: false,
|
|
||||||
cwd: resolvedRoot,
|
|
||||||
filePath: tempConfigPath,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
result = await load('tailwind', {
|
||||||
|
mustExist: false,
|
||||||
|
cwd: resolvedRoot,
|
||||||
|
filePath: tempConfigPath,
|
||||||
|
});
|
||||||
|
|
||||||
await fs.unlink(tempConfigPath);
|
await fs.unlink(tempConfigPath);
|
||||||
} catch {
|
} catch {
|
||||||
/** file already removed */
|
/** file already removed */
|
||||||
|
|
Loading…
Add table
Reference in a new issue