Fix build output for endpoints route (#4273)
* Fix build output for endpoints route * Add changeset
This commit is contained in:
parent
d3d09a2c9f
commit
0022f46b57
3 changed files with 12 additions and 3 deletions
5
.changeset/rude-birds-ring.md
Normal file
5
.changeset/rude-birds-ring.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix build output adding `/index.html` at the end of endpoints route
|
|
@ -161,7 +161,7 @@ async function generatePage(
|
||||||
const timeEnd = performance.now();
|
const timeEnd = performance.now();
|
||||||
const timeChange = getTimeStat(timeStart, timeEnd);
|
const timeChange = getTimeStat(timeStart, timeEnd);
|
||||||
const timeIncrease = `(+${timeChange})`;
|
const timeIncrease = `(+${timeChange})`;
|
||||||
const filePath = getOutputFilename(opts.astroConfig, path);
|
const filePath = getOutputFilename(opts.astroConfig, path, pageData.route.type);
|
||||||
const lineIcon = i === paths.length - 1 ? '└─' : '├─';
|
const lineIcon = i === paths.length - 1 ? '└─' : '├─';
|
||||||
info(opts.logging, null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
info(opts.logging, null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import resolve from 'resolve';
|
||||||
import slash from 'slash';
|
import slash from 'slash';
|
||||||
import { fileURLToPath, pathToFileURL } from 'url';
|
import { fileURLToPath, pathToFileURL } from 'url';
|
||||||
import type { ErrorPayload, ViteDevServer } from 'vite';
|
import type { ErrorPayload, ViteDevServer } from 'vite';
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig, RouteType } from '../@types/astro';
|
||||||
import { prependForwardSlash, removeTrailingForwardSlash } from './path.js';
|
import { prependForwardSlash, removeTrailingForwardSlash } from './path.js';
|
||||||
|
|
||||||
// process.env.PACKAGE_VERSION is injected when we build and publish the astro package.
|
// process.env.PACKAGE_VERSION is injected when we build and publish the astro package.
|
||||||
|
@ -33,7 +33,11 @@ const STATUS_CODE_REGEXP = /^\/?[0-9]{3}$/;
|
||||||
* Handles both "/foo" and "foo" `name` formats.
|
* Handles both "/foo" and "foo" `name` formats.
|
||||||
* Handles `/404` and `/` correctly.
|
* Handles `/404` and `/` correctly.
|
||||||
*/
|
*/
|
||||||
export function getOutputFilename(astroConfig: AstroConfig, name: string) {
|
export function getOutputFilename(astroConfig: AstroConfig, name: string, type: RouteType) {
|
||||||
|
if (type === 'endpoint') {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
if (name === '/' || name === '') {
|
if (name === '/' || name === '') {
|
||||||
return path.posix.join(name, 'index.html');
|
return path.posix.join(name, 'index.html');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue