Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { AstroSettings, RoutesList } from '../types/astro.js';
import { vitePluginAdapterConfig } from '../vite-plugin-adapter-config/index.js';
import { vitePluginApp } from '../vite-plugin-app/index.js';
import astroVitePlugin from '../vite-plugin-astro/index.js';
import { vitePluginAstroServer } from '../vite-plugin-astro-server/index.js';
import { vitePluginAstroServer, vitePluginAstroServerClient } from '../vite-plugin-astro-server/index.js';
import configAliasVitePlugin from '../vite-plugin-config-alias/index.js';
import { astroDevCssPlugin } from '../vite-plugin-css/index.js';
import vitePluginFileURL from '../vite-plugin-fileurl/index.js';
Expand Down Expand Up @@ -161,6 +161,7 @@ export async function createVite(
// the build to run very slow as the filewatcher is triggered often.
command === 'dev' && vitePluginApp(),
command === 'dev' && vitePluginAstroServer({ settings, logger }),
command === 'dev' && vitePluginAstroServerClient(),
astroDevCssPlugin({ routesList, command }),
importMetaEnv({ envLoader }),
astroEnv({ settings, sync, envLoader }),
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createController, runWithErrorHandling } from './controller.js';

Check failure on line 1 in packages/astro/src/vite-plugin-astro-server/index.ts

View workflow job for this annotation

GitHub Actions / Lint

assist/source/organizeImports

The imports and exports are not sorted.
export { default as vitePluginAstroServer } from './plugin.js';
export { default as vitePluginAstroServer, createVitePluginAstroServerClient as vitePluginAstroServerClient } from './plugin.js';
17 changes: 17 additions & 0 deletions packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ export default function createVitePluginAstroServer({
};
}

export function createVitePluginAstroServerClient(): vite.Plugin {
return {
name: 'astro:server-client',
applyToEnvironment(environment) {
return environment.name === 'client';
},
transform(code, id, opts = {}) {
if (opts.ssr) return;
if (!id.includes('vite/dist/client/client.mjs')) return;

// Replace the Vite overlay with ours
return patchOverlay(code);
}
}
}


/**
* It creates a `SSRManifest` from the `AstroSettings`.
*
Expand Down
Loading