mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): handle pages with no content and log warning (#20373)
This commit is contained in:
parent
820fecd9ee
commit
48b48dec00
@ -109,7 +109,14 @@ export const PageMetaPlugin = createUnplugin((options: PageMetaPluginOptions) =>
|
||||
}
|
||||
|
||||
if (!hasMacro && !code.includes('export { default }') && !code.includes('__nuxt_page_meta')) {
|
||||
if (!code) {
|
||||
s.append(CODE_EMPTY + (options.dev ? CODE_HMR : ''))
|
||||
const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href))
|
||||
console.error(`The file \`${pathname}\` is not a valid page as it has no content.`)
|
||||
} else {
|
||||
s.overwrite(0, code.length, CODE_EMPTY + (options.dev ? CODE_HMR : ''))
|
||||
}
|
||||
|
||||
return result()
|
||||
}
|
||||
|
||||
|
0
test/fixtures/basic/pages/empty.ts
vendored
Normal file
0
test/fixtures/basic/pages/empty.ts
vendored
Normal file
Loading…
Reference in New Issue
Block a user