diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index 726f50d6bc..4703749e32 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -349,7 +349,8 @@ export default class Builder {
}
return
}
- if (!templateVars.layouts[name] && /\.vue$/.test(file)) {
+ // .vue file takes precedence over other extensions
+ if (!templateVars.layouts[name] || /\.vue$/.test(file)) {
templateVars.layouts[name] = this.relativeToBuild(
this.options.srcDir,
file
@@ -382,6 +383,7 @@ export default class Builder {
ignore: this.options.ignore
})).forEach((f) => {
const key = f.replace(new RegExp(`\\.(${this.supportedExtensions.join('|')})$`), '')
+ // .vue file takes precedence over other extensions
if (/\.vue$/.test(f) || !files[key]) {
files[key] = f.replace(/(['"])/g, '\\$1')
}
diff --git a/test/fixtures/basic/layouts/custom.js b/test/fixtures/basic/layouts/custom.js
new file mode 100644
index 0000000000..b0bcd797b8
--- /dev/null
+++ b/test/fixtures/basic/layouts/custom.js
@@ -0,0 +1,10 @@
+export default {
+ render(h) {
+ return h('div',
+ [
+ h('h1', 'JS Layout'),
+ h('nuxt')
+ ]
+ )
+ }
+}
diff --git a/test/fixtures/basic/layouts/default.vue b/test/fixtures/basic/layouts/default.vue
new file mode 100644
index 0000000000..0acb4c7997
--- /dev/null
+++ b/test/fixtures/basic/layouts/default.vue
@@ -0,0 +1,5 @@
+
+
-
+
-
+