mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
fix(astro): do not open new tab when saving config files (#11456)
This commit is contained in:
parent
33fc991472
commit
224110f307
2 changed files with 20 additions and 1 deletions
5
.changeset/proud-singers-call.md
Normal file
5
.changeset/proud-singers-call.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes `astro dev --open` unexpected behavior that spawns a new tab every time a config file is saved
|
|
@ -56,9 +56,23 @@ export async function createContainer({
|
||||||
base,
|
base,
|
||||||
server: { host, headers, open: serverOpen },
|
server: { host, headers, open: serverOpen },
|
||||||
} = settings.config;
|
} = settings.config;
|
||||||
|
|
||||||
|
// serverOpen = true, isRestart = false
|
||||||
|
// when astro dev --open command is run the first time
|
||||||
|
// expected behavior: spawn a new tab
|
||||||
|
// ------------------------------------------------------
|
||||||
|
// serverOpen = true, isRestart = true
|
||||||
|
// when config file is saved
|
||||||
|
// expected behavior: do not spawn a new tab
|
||||||
|
// ------------------------------------------------------
|
||||||
|
// Non-config files don't reach this point
|
||||||
|
const isServerOpenURL = typeof serverOpen == 'string' && !isRestart;
|
||||||
|
const isServerOpenBoolean = serverOpen && !isRestart;
|
||||||
|
|
||||||
// Open server to the correct path. We pass the `base` here as we didn't pass the
|
// Open server to the correct path. We pass the `base` here as we didn't pass the
|
||||||
// base to the initial Vite config
|
// base to the initial Vite config
|
||||||
const open = typeof serverOpen == 'string' ? serverOpen : serverOpen ? base : false;
|
const open = isServerOpenURL ? serverOpen
|
||||||
|
: isServerOpenBoolean ? base : false;
|
||||||
|
|
||||||
// The client entrypoint for renderers. Since these are imported dynamically
|
// The client entrypoint for renderers. Since these are imported dynamically
|
||||||
// we need to tell Vite to preoptimize them.
|
// we need to tell Vite to preoptimize them.
|
||||||
|
|
Loading…
Add table
Reference in a new issue