From 3c5cb69488c76bbf0e9774fff5d948d29990515c Mon Sep 17 00:00:00 2001 From: impcyber Date: Tue, 15 Nov 2022 23:26:37 +0300 Subject: [PATCH] Fix: https://github.com/withastro/astro/issues/5400 (#5410) * Fix: Astro generates empty .-index.bundle.js https://github.com/withastro/astro/issues/5400 * Create loud-penguins-tickle.md --- .changeset/loud-penguins-tickle.md | 5 +++++ packages/astro/src/core/build/css-asset-name.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/loud-penguins-tickle.md diff --git a/.changeset/loud-penguins-tickle.md b/.changeset/loud-penguins-tickle.md new file mode 100644 index 000000000..1076db0d3 --- /dev/null +++ b/.changeset/loud-penguins-tickle.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix: https://github.com/withastro/astro/issues/5400 diff --git a/packages/astro/src/core/build/css-asset-name.ts b/packages/astro/src/core/build/css-asset-name.ts index 225dd12aa..c9e4a418e 100644 --- a/packages/astro/src/core/build/css-asset-name.ts +++ b/packages/astro/src/core/build/css-asset-name.ts @@ -25,6 +25,7 @@ export function shortHashedName(id: string, ctx: { getModuleInfo: GetModuleInfo export function createSlugger(settings: AstroSettings) { const pagesDir = viteID(new URL('./pages', settings.config.srcDir)); + const indexPage = viteID(new URL("./pages/index", settings.config.srcDir)); const map = new Map>(); const sep = '-'; return function (id: string, ctx: { getModuleInfo: GetModuleInfo }): string { @@ -33,7 +34,7 @@ export function createSlugger(settings: AstroSettings) { .map(([page]) => page.id) .sort() .join('-'); - const firstParentId = parents[0]?.[0].id || 'index'; + const firstParentId = parents[0]?.[0].id || indexPage; // Use the last two segments, for ex /docs/index let dir = firstParentId;