diff --git a/lib/app/App.vue b/lib/app/App.vue index ae205ceecf..5592b88f2a 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -20,6 +20,8 @@ layoutsKeys.forEach(function (key, i) { %> <% }) %> } +let resolvedLayouts = {} + export default { head: <%= JSON.stringify(head) %>, data: () => ({ @@ -37,22 +39,23 @@ export default { }, methods: { setLayout (layout) { - if (!layout || !layouts['_' + layout]) layout = 'default' + if (!layout || !resolvedLayouts['_' + layout]) layout = 'default' this.layoutName = layout let _layout = '_' + layout - this.layout = layouts[_layout] + this.layout = resolvedLayouts[_layout] return this.layout }, loadLayout (layout) { - if (!layout || !layouts['_' + layout]) layout = 'default' + if (!layout || !(layouts['_' + layout] || resolvedLayouts['_' + layout])) layout = 'default' let _layout = '_' + layout - if (typeof layouts[_layout] !== 'function') { - return Promise.resolve(layouts[_layout]) + if (resolvedLayouts[_layout]) { + return Promise.resolve(resolvedLayouts[_layout]) } return layouts[_layout]() .then((Component) => { - layouts[_layout] = Component - return layouts[_layout] + resolvedLayouts[_layout] = Component + delete layouts[_layout] + return resolvedLayouts[_layout] }) .catch((e) => { if (this.$nuxt) { diff --git a/lib/app/server.js b/lib/app/server.js index 11f011ea0b..b45c4dad79 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -79,7 +79,7 @@ export default async context => { let Components = [] try { Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => { - if (typeof Component !== 'function' || Component.super === Vue) { + if (typeof Component !== 'function' || Component.cid) { return sanitizeComponent(Component) } return Component().then(Component => sanitizeComponent(Component)) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index 659eded04b..385fa49425 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -20,6 +20,10 @@ export default function ({ isClient }) { 'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'), 'styl': styleLoader.call(this, 'stylus', 'stylus-loader') }, + template: { + // for pug, see https://github.com/vuejs/vue-loader/issues/55 + doctype: 'html' + }, preserveWhitespace: false, extractCSS: extractStyles.call(this) }