fix: hide error overlay tip, log [astro] instead of [vite] (#4162)

Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
Nate Moore 2022-08-05 10:39:24 -05:00 committed by GitHub
parent e569f0a5c7
commit 9014f0f8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -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: '',
});

View file

@ -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]')
}
};
}