Skip to content

Commit 2cff904

Browse files
authored
fix: adjust page warning to only show up in more relevant times (#15127)
* fix: adjust page warning to only show up in more relevant times * chore: changeset
1 parent d40ff7d commit 2cff904

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

.changeset/proud-singers-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Updates "Unsupported page types found" error to only appear in more realistic cases

packages/astro/src/core/routing/manifest/create.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function createFileBasedRoutes(
119119
...SUPPORTED_MARKDOWN_FILE_EXTENSIONS,
120120
...settings.pageExtensions,
121121
]);
122+
const invalidPotentialPages = new Set<string>(['.tsx', '.jsx', '.vue', '.svelte']);
122123
const validEndpointExtensions = new Set<string>(['.js', '.ts']);
123124
const localFs = fsMod ?? nodeFs;
124125
const prerender = getPrerenderDefault(settings.config);
@@ -146,12 +147,17 @@ function createFileBasedRoutes(
146147
}
147148
// filter out "foo.astro_tmp" files, etc
148149
if (!isDir && !validPageExtensions.has(ext) && !validEndpointExtensions.has(ext)) {
149-
logger.warn(
150-
null,
151-
`Unsupported file type ${colors.bold(
152-
resolved,
153-
)} found. Prefix filename with an underscore (\`_\`) to ignore.`,
154-
);
150+
151+
// Only warn for files that could potentially be interpreted by users has being possible extensions for pages
152+
// It's otherwise not a problem for users to have other files in their pages directory, for instance colocated images.
153+
if (invalidPotentialPages.has(ext)) {
154+
logger.warn(
155+
null,
156+
`Unsupported file type ${colors.bold(
157+
resolved,
158+
)} found in pages directory. Only Astro files can be used as pages. Prefix filename with an underscore (\`_\`) to ignore this warning, or move the file outside of the pages directory.`,
159+
);
160+
}
155161

156162
continue;
157163
}

0 commit comments

Comments
 (0)