From 3ff11546d1ab5b6a214f8fdfac1982b7145cc877 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 10 Aug 2023 11:21:47 -0400 Subject: [PATCH 1/2] fix(#6067): dev server restart respects base removal --- .changeset/funny-eels-jog.md | 5 +++ packages/astro/src/template/4xx.ts | 37 +++++++++++++++++-- .../src/vite-plugin-astro-server/plugin.ts | 11 +++--- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 .changeset/funny-eels-jog.md diff --git a/.changeset/funny-eels-jog.md b/.changeset/funny-eels-jog.md new file mode 100644 index 000000000000..2481c24dff91 --- /dev/null +++ b/.changeset/funny-eels-jog.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Ensure dev server restarts respect when `base` is removed diff --git a/packages/astro/src/template/4xx.ts b/packages/astro/src/template/4xx.ts index c5d87929e4cd..6ad3bb2cc8d5 100644 --- a/packages/astro/src/template/4xx.ts +++ b/packages/astro/src/template/4xx.ts @@ -28,14 +28,40 @@ export default function template({ ${tabTitle} diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 681aac3411ab..8f74bd47afe3 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -44,12 +44,11 @@ export default function createVitePluginAstroServer({ return () => { // Push this middleware to the front of the stack so that it can intercept responses. - if (settings.config.base !== '/') { - viteServer.middlewares.stack.unshift({ - route: '', - handle: baseMiddleware(settings, logging), - }); - } + // fix(#6067): always inject this to ensure zombie base handling is killed after restarts + viteServer.middlewares.stack.unshift({ + route: '', + handle: baseMiddleware(settings, logging), + }); // Note that this function has a name so other middleware can find it. viteServer.middlewares.use(async function astroDevHandler(request, response) { if (request.url === undefined || !request.method) { From 13514d1b71e2ff3bf42933593515daab6fbc08ed Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 10 Aug 2023 11:32:30 -0400 Subject: [PATCH 2/2] chore: remove baseCss --- packages/astro/src/template/4xx.ts | 1 - packages/astro/src/template/css.ts | 50 ------------------------------ 2 files changed, 51 deletions(-) delete mode 100644 packages/astro/src/template/css.ts diff --git a/packages/astro/src/template/4xx.ts b/packages/astro/src/template/4xx.ts index 6ad3bb2cc8d5..45f4ac10ae90 100644 --- a/packages/astro/src/template/4xx.ts +++ b/packages/astro/src/template/4xx.ts @@ -1,5 +1,4 @@ import { escape } from 'html-escaper'; -import { baseCSS } from './css.js'; interface ErrorTemplateOptions { /** a short description of the error */ diff --git a/packages/astro/src/template/css.ts b/packages/astro/src/template/css.ts deleted file mode 100644 index 87fbfd1b8f6c..000000000000 --- a/packages/astro/src/template/css.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * CSS is exported as a string so the error pages: - * 1. don’t need to resolve a deep internal CSS import - * 2. don’t need external dependencies to render (they may be shown because of a dep!) - */ - -// Base CSS: shared CSS among pages -export const baseCSS = ` -:root { - --gray-10: hsl(258, 7%, 10%); - --gray-20: hsl(258, 7%, 20%); - --gray-30: hsl(258, 7%, 30%); - --gray-40: hsl(258, 7%, 40%); - --gray-50: hsl(258, 7%, 50%); - --gray-60: hsl(258, 7%, 60%); - --gray-70: hsl(258, 7%, 70%); - --gray-80: hsl(258, 7%, 80%); - --gray-90: hsl(258, 7%, 90%); - --orange: #ff5d01; -} - -* { - box-sizing: border-box; -} - -body { - background-color: var(--gray-10); - color: var(--gray-80); - font-family: monospace; - line-height: 1.5; - margin: 0; -} - -a { - color: var(--orange); -} - -h1 { - font-weight: 800; - margin-top: 1rem; - margin-bottom: 0; -} - -pre { - color:; - font-size: 1.2em; - margin-top: 0; - max-width: 60em; -} -`;