diff --git a/packages/astro/src/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.ts b/packages/astro/src/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.ts index 4e9526993c..d7e0a106d4 100644 --- a/packages/astro/src/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.ts +++ b/packages/astro/src/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.ts @@ -25,9 +25,18 @@ export default function astroDevToolbar({ settings }: AstroPluginOptions): vite. return ` export const loadDevToolbarApps = async () => { return [${settings.devToolbarApps - .map((plugin) => `(await import(${JSON.stringify(plugin)})).default`) - .join(',')}]; + .map((plugin) => `await safeLoadPlugin(${JSON.stringify(plugin)})`) + .join(',')}].filter(app => app !== undefined)); }; + + async function safeLoadPlugin(entrypoint) { + try { + return (await import(entrypoint)).default; + } catch (err) { + console.error("Failed to load dev toolbar app from", entrypoint, err); + return undefined; + } + } `; } },