diff options
author | 2023-08-07 15:54:55 -0500 | |
---|---|---|
committer | 2023-08-07 15:54:55 -0500 | |
commit | 8e5a27b488b326c1f9be6f02c191a2fb0dafac56 (patch) | |
tree | ca2353d1dfa48fc7cb1546243b1d7040d95a22e0 | |
parent | 2c2e9362a2bb297f000b390614d91fb875658c16 (diff) | |
download | astro-8e5a27b488b326c1f9be6f02c191a2fb0dafac56.tar.gz astro-8e5a27b488b326c1f9be6f02c191a2fb0dafac56.tar.zst astro-8e5a27b488b326c1f9be6f02c191a2fb0dafac56.zip |
fix: ensure `injectRoute` works during build (#7986)
-rw-r--r-- | .changeset/red-bikes-return.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/create-vite.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/vite-plugin-integrations-container/index.ts | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/red-bikes-return.md b/.changeset/red-bikes-return.md new file mode 100644 index 000000000..91537b5f1 --- /dev/null +++ b/.changeset/red-bikes-return.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Ensure injectRoute is properly handled in `build` as well as `dev` diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index c0b989b77..0fb64ef69 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -123,7 +123,7 @@ export async function createVite( htmlVitePlugin(), jsxVitePlugin({ settings, logging }), astroPostprocessVitePlugin(), - mode === 'dev' && astroIntegrationsContainerPlugin({ settings, logging }), + astroIntegrationsContainerPlugin({ settings, logging }), astroScriptsPageSSRPlugin({ settings }), astroHeadPlugin(), astroScannerPlugin({ settings, logging }), diff --git a/packages/astro/src/vite-plugin-integrations-container/index.ts b/packages/astro/src/vite-plugin-integrations-container/index.ts index f2fd52fa7..d6bfd76d7 100644 --- a/packages/astro/src/vite-plugin-integrations-container/index.ts +++ b/packages/astro/src/vite-plugin-integrations-container/index.ts @@ -17,9 +17,11 @@ export default function astroIntegrationsContainerPlugin({ return { name: 'astro:integration-container', configureServer(server) { + if (server.config.isProduction) return; runHookServerSetup({ config: settings.config, server, logging }); }, async buildStart() { + if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length) return; // Ensure the injectedRoutes are all resolved to their final paths through Rollup settings.resolvedInjectedRoutes = await Promise.all( settings.injectedRoutes.map((route) => resolveEntryPoint.call(this, route)) |