diff options
author | 2022-01-11 11:24:57 -0500 | |
---|---|---|
committer | 2022-01-11 11:24:57 -0500 | |
commit | 1007497297769455d41e23f48dfdbec90b403f2e (patch) | |
tree | 80fb321abf59e62446517100b24720b1fd3c26fc | |
parent | f482c626a6e3472052d13cb0d348323ef4e822a8 (diff) | |
download | astro-1007497297769455d41e23f48dfdbec90b403f2e.tar.gz astro-1007497297769455d41e23f48dfdbec90b403f2e.tar.zst astro-1007497297769455d41e23f48dfdbec90b403f2e.zip |
Fix build output in static build mode (#2358)
* Fix build output in static build mode
* Adds a changeset
* Formatting
-rw-r--r-- | .changeset/selfish-scissors-repeat.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/build/index.ts | 1 | ||||
-rw-r--r-- | packages/astro/src/core/build/static-build.ts | 11 |
3 files changed, 16 insertions, 1 deletions
diff --git a/.changeset/selfish-scissors-repeat.md b/.changeset/selfish-scissors-repeat.md new file mode 100644 index 000000000..8568a25a8 --- /dev/null +++ b/.changeset/selfish-scissors-repeat.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes the output when using the experimental-static-build flag diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index fd73e0d93..3c08f4f61 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -101,6 +101,7 @@ class AstroBuilder { astroConfig: this.config, logging: this.logging, origin: this.origin, + pageNames, routeCache: this.routeCache, viteConfig: this.viteConfig, }); diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index d37fb48ac..c424ec92d 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -25,10 +25,16 @@ export interface StaticBuildOptions { astroConfig: AstroConfig; logging: LogOptions; origin: string; + pageNames: string[]; routeCache: RouteCache; viteConfig: ViteConfigWithSSR; } +function addPageName(pathname: string, opts: StaticBuildOptions): void { + const pathrepl = opts.astroConfig.buildOptions.pageUrlFormat === 'directory' ? '/index.html' : pathname === '/' ? 'index.html' : '.html'; + opts.pageNames.push(pathname.replace(/\/?$/, pathrepl).replace(/^\//, '')); +} + export async function staticBuild(opts: StaticBuildOptions) { const { allPages, astroConfig } = opts; @@ -198,9 +204,12 @@ interface GeneratePathOptions { } async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: GeneratePathOptions) { - const { astroConfig, logging, origin, routeCache } = opts; + const { astroConfig, logging, origin, pageNames, routeCache } = opts; const { Component, internals, linkIds, pageData } = gopts; + // This adds the page name to the array so it can be shown as part of stats. + addPageName(pathname, opts); + const [renderers, mod] = pageData.preload; try { |