Skip to content

Commit

Permalink
fix: hide error overlay tip, log [astro] instead of [vite] (#4162)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
natemoo-re and natemoo-re authored Aug 5, 2022
1 parent e569f0a commit 9014f0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
});
Expand Down
8 changes: 8 additions & 0 deletions packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]')
}
};
}

0 comments on commit 9014f0f

Please sign in to comment.