mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-01 18:07:22 +00:00
fix(nuxt): respect false
to disable spa loading template (#21739)
This commit is contained in:
parent
88bc32d42a
commit
068ab19aab
@ -31,11 +31,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
|||||||
? [new RegExp(`node_modules\\/(?!${excludePaths.join('|')})`)]
|
? [new RegExp(`node_modules\\/(?!${excludePaths.join('|')})`)]
|
||||||
: [/node_modules/]
|
: [/node_modules/]
|
||||||
|
|
||||||
const spaLoadingTemplatePath = nuxt.options.spaLoadingTemplate ?? resolve(nuxt.options.srcDir, 'app/spa-loading-template.html')
|
const spaLoadingTemplate = nuxt.options.spaLoadingTemplate ?? resolve(nuxt.options.srcDir, 'app/spa-loading-template.html')
|
||||||
if (spaLoadingTemplatePath !== false && !existsSync(spaLoadingTemplatePath)) {
|
if (spaLoadingTemplate && nuxt.options.spaLoadingTemplate && !existsSync(spaLoadingTemplate)) {
|
||||||
if (nuxt.options.spaLoadingTemplate) {
|
console.warn(`[nuxt] Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${spaLoadingTemplate}\`.`)
|
||||||
console.warn(`[nuxt] Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${spaLoadingTemplatePath}\`.`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nitroConfig: NitroConfig = defu(_nitroConfig, {
|
const nitroConfig: NitroConfig = defu(_nitroConfig, {
|
||||||
@ -87,10 +85,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
|||||||
virtual: {
|
virtual: {
|
||||||
'#internal/nuxt.config.mjs': () => nuxt.vfs['#build/nuxt.config'],
|
'#internal/nuxt.config.mjs': () => nuxt.vfs['#build/nuxt.config'],
|
||||||
'#spa-template': () => {
|
'#spa-template': () => {
|
||||||
|
if (!spaLoadingTemplate) { return 'export const template = ""' }
|
||||||
try {
|
try {
|
||||||
if (spaLoadingTemplatePath) {
|
return `export const template = ${JSON.stringify(readFileSync(spaLoadingTemplate, 'utf-8'))}`
|
||||||
return `export const template = ${JSON.stringify(readFileSync(spaLoadingTemplatePath, 'utf-8'))}`
|
|
||||||
}
|
|
||||||
} catch {}
|
} catch {}
|
||||||
return `export const template = ${JSON.stringify(defaultSpaLoadingTemplate({}))}`
|
return `export const template = ${JSON.stringify(defaultSpaLoadingTemplate({}))}`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user