Fix build output in static build mode (#2358)
* Fix build output in static build mode * Adds a changeset * Formatting
This commit is contained in:
parent
f482c626a6
commit
1007497297
3 changed files with 16 additions and 1 deletions
5
.changeset/selfish-scissors-repeat.md
Normal file
5
.changeset/selfish-scissors-repeat.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes the output when using the experimental-static-build flag
|
|
@ -101,6 +101,7 @@ class AstroBuilder {
|
|||
astroConfig: this.config,
|
||||
logging: this.logging,
|
||||
origin: this.origin,
|
||||
pageNames,
|
||||
routeCache: this.routeCache,
|
||||
viteConfig: this.viteConfig,
|
||||
});
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue