File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
packages/astro/src/vite-plugin-scanner Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' astro ' : patch
3+ ---
4+
5+ Check for ` getStaticPaths ` only if the file has the ` .astro ` extension.
Original file line number Diff line number Diff line change @@ -8,12 +8,15 @@ import { warn } from '../core/logger/core.js';
88import { isEndpoint , isPage , rootRelativePath } from '../core/util.js' ;
99import { getPrerenderDefault , isServerLikeOutput } from '../prerender/utils.js' ;
1010import { scan } from './scan.js' ;
11+ import { extname } from 'node:path' ;
1112
1213export interface AstroPluginScannerOptions {
1314 settings : AstroSettings ;
1415 logging : LogOptions ;
1516}
1617
18+ const KNOWN_FILE_EXTENSIONS = [ '.astro' , '.js' , '.ts' ] ;
19+
1720export default function astroScannerPlugin ( {
1821 settings,
1922 logging,
@@ -43,12 +46,13 @@ export default function astroScannerPlugin({
4346 if ( typeof pageOptions . prerender === 'undefined' ) {
4447 pageOptions . prerender = defaultPrerender ;
4548 }
46-
4749 // `getStaticPaths` warning is just a string check, should be good enough for most cases
4850 if (
4951 ! pageOptions . prerender &&
5052 isServerLikeOutput ( settings . config ) &&
51- code . includes ( 'getStaticPaths' )
53+ code . includes ( 'getStaticPaths' ) &&
54+ // this should only be valid for `.astro`, `.js` and `.ts` files
55+ KNOWN_FILE_EXTENSIONS . includes ( extname ( filename ) )
5256 ) {
5357 const reason = ` because \`output: "${ settings . config . output } "\` is set` ;
5458 warn (
You can’t perform that action at this time.
0 commit comments