From 3e41a6750b0372b1cb83e9d53d6fed64aeed7a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Aug 2017 14:15:00 +0200 Subject: [PATCH] Update builder.js --- lib/builder/builder.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index f9362275b4..eb891f9858 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -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