Skip to content

Commit 1b8d302

Browse files
authored
Ensure dev server restart respects base removal (#8027)
* fix(#6067): dev server restart respects base removal * chore: remove baseCss
1 parent 3bc74dd commit 1b8d302

File tree

4 files changed

+44
-60
lines changed

4 files changed

+44
-60
lines changed

.changeset/funny-eels-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Ensure dev server restarts respect when `base` is removed

packages/astro/src/template/4xx.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { escape } from 'html-escaper';
2-
import { baseCSS } from './css.js';
32

43
interface ErrorTemplateOptions {
54
/** a short description of the error */
@@ -28,14 +27,40 @@ export default function template({
2827
<meta charset="UTF-8">
2928
<title>${tabTitle}</title>
3029
<style>
31-
${baseCSS}
3230
:root {
31+
--gray-10: hsl(258, 7%, 10%);
32+
--gray-20: hsl(258, 7%, 20%);
33+
--gray-30: hsl(258, 7%, 30%);
34+
--gray-40: hsl(258, 7%, 40%);
35+
--gray-50: hsl(258, 7%, 50%);
36+
--gray-60: hsl(258, 7%, 60%);
37+
--gray-70: hsl(258, 7%, 70%);
38+
--gray-80: hsl(258, 7%, 80%);
39+
--gray-90: hsl(258, 7%, 90%);
3340
--black: #13151A;
3441
--accent-light: #E0CCFA;
3542
}
3643
37-
body {
44+
* {
45+
box-sizing: border-box;
46+
}
47+
48+
html {
3849
background: var(--black);
50+
color-scheme: dark;
51+
accent-color: var(--accent-light);
52+
}
53+
54+
body {
55+
background-color: var(--gray-10);
56+
color: var(--gray-80);
57+
font-family: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
58+
line-height: 1.5;
59+
margin: 0;
60+
}
61+
62+
a {
63+
color: var(--accent-light);
3964
}
4065
4166
.center {
@@ -52,6 +77,8 @@ export default function template({
5277
color: white;
5378
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
5479
font-weight: 700;
80+
margin-top: 1rem;
81+
margin-bottom: 0;
5582
}
5683
5784
.statusCode {
@@ -63,11 +90,14 @@ export default function template({
6390
width: 124px;
6491
}
6592
66-
pre {
93+
pre, code {
6794
padding: 2px 8px;
6895
background: rgba(0,0,0, 0.25);
6996
border: 1px solid rgba(255,255,255, 0.25);
7097
border-radius: 4px;
98+
font-size: 1.2em;
99+
margin-top: 0;
100+
max-width: 60em;
71101
}
72102
</style>
73103
</head>

packages/astro/src/template/css.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/astro/src/vite-plugin-astro-server/plugin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ export default function createVitePluginAstroServer({
4444

4545
return () => {
4646
// Push this middleware to the front of the stack so that it can intercept responses.
47-
if (settings.config.base !== '/') {
48-
viteServer.middlewares.stack.unshift({
49-
route: '',
50-
handle: baseMiddleware(settings, logging),
51-
});
52-
}
47+
// fix(#6067): always inject this to ensure zombie base handling is killed after restarts
48+
viteServer.middlewares.stack.unshift({
49+
route: '',
50+
handle: baseMiddleware(settings, logging),
51+
});
5352
// Note that this function has a name so other middleware can find it.
5453
viteServer.middlewares.use(async function astroDevHandler(request, response) {
5554
if (request.url === undefined || !request.method) {

0 commit comments

Comments
 (0)