mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
Update builder.js
This commit is contained in:
parent
814590c15a
commit
3e41a6750b
@ -162,17 +162,17 @@ export default class Builder extends Tapable {
|
||||
// -- Layouts --
|
||||
if (fs.existsSync(resolve(this.options.srcDir, 'layouts'))) {
|
||||
const layoutsFiles = await glob('layouts/*.{vue,js}', { cwd: this.options.srcDir })
|
||||
let hasErrorLayout = false
|
||||
layoutsFiles.forEach((file) => {
|
||||
let name = file.split('/').slice(-1)[0].replace('.vue', '').replace('.js', '')
|
||||
if (name === 'error') return
|
||||
let name = file.split('/').slice(-1)[0].replace(/\.(js|vue)$/, '')
|
||||
if (name === 'error') {
|
||||
hasErrorLayout = true
|
||||
return
|
||||
}
|
||||
templateVars.layouts[name] = this.relativeToBuild(this.options.srcDir, file)
|
||||
})
|
||||
if (!templateVars.components.ErrorPage) {
|
||||
if (layoutsFiles.includes('layouts/error.vue')) {
|
||||
templateVars.components.ErrorPage = this.relativeToBuild(this.options.srcDir, 'layouts/error.vue')
|
||||
} else if (layoutsFiles.includes('layouts/error.js')) {
|
||||
templateVars.components.ErrorPage = this.relativeToBuild(this.options.srcDir, 'layouts/error.js')
|
||||
}
|
||||
if (!templateVars.components.ErrorPage && hasErrorLayout) {
|
||||
templateVars.components.ErrorPage = this.relativeToBuild(this.options.srcDir, 'layouts/error')
|
||||
}
|
||||
}
|
||||
// If no default layout, create its folder and add the default folder
|
||||
|
Loading…
Reference in New Issue
Block a user