From c857402d310800eeb2136a324a080afdf1a1cd0b Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 4 Aug 2022 22:48:44 -0500 Subject: [PATCH] fix: hide error overlay tip, log [astro] instead of [vite] --- packages/astro/src/core/render/dev/index.ts | 2 +- packages/astro/src/vite-plugin-astro-server/index.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index c9e64dfb4598..7de9a979a45f 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -120,7 +120,7 @@ export async function render( scripts.add({ props: { type: 'module', - src: new URL('../../../runtime/client/hmr.js', import.meta.url).pathname, + src: '/@id/astro/runtime/client/hmr.js', }, children: '', }); diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index 282d1e49b097..99a749a3dc5f 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -406,5 +406,13 @@ export default function createPlugin({ config, logging }: AstroPluginOptions): v }); }; }, + // HACK: hide `.tip` in Vite's ErrorOverlay and replace [vite] messages with [astro] + transform(code, id, opts = {}) { + if (opts.ssr) return; + if (!id.includes('vite/dist/client/client.mjs')) return; + return code + .replace(/\.tip \{[^}]*\}/gm, '.tip {\n display: none;\n}') + .replace(/\[vite\]/g, '[astro]') + } }; }