From a15975e41cb5eaf6ed8eb3ebaee676a17e433052 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 8 Apr 2024 13:33:09 +0800 Subject: [PATCH] Skip prerender chunk in static output (#10695) --- .changeset/plenty-bugs-hunt.md | 5 +++++ packages/astro/src/core/build/plugins/plugin-prerender.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/plenty-bugs-hunt.md diff --git a/.changeset/plenty-bugs-hunt.md b/.changeset/plenty-bugs-hunt.md new file mode 100644 index 000000000000..179310ea97b0 --- /dev/null +++ b/.changeset/plenty-bugs-hunt.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Skips prerender chunk if building with static output diff --git a/packages/astro/src/core/build/plugins/plugin-prerender.ts b/packages/astro/src/core/build/plugins/plugin-prerender.ts index ce9f925ee339..171d998b7b9b 100644 --- a/packages/astro/src/core/build/plugins/plugin-prerender.ts +++ b/packages/astro/src/core/build/plugins/plugin-prerender.ts @@ -68,7 +68,6 @@ function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals } } - opts.allPages; pageInfo.hasSharedModules = hasSharedModules; pageInfo.route.prerender = true; return 'prerender'; @@ -87,6 +86,11 @@ export function pluginPrerender( opts: StaticBuildOptions, internals: BuildInternals ): AstroBuildPlugin { + // Static output can skip prerender completely because we're already rendering all pages + if (opts.settings.config.output === 'static') { + return { targets: ['server'] }; + } + return { targets: ['server'], hooks: {