0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

fix: ensure injectRoute works during build (#7986)

This commit is contained in:
Nate Moore 2023-08-07 15:54:55 -05:00 committed by GitHub
parent 2c2e9362a2
commit 8e5a27b488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Ensure injectRoute is properly handled in `build` as well as `dev`

View file

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

View file

@ -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))