diff --git a/lib/app/client.js b/lib/app/client.js index d3ab2760b3..216b8ded79 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -528,10 +528,12 @@ async function mountApp(__app) { // Create Vue instance const _app = new Vue(app) - // Load layout + <% if (mode !== 'spa') { %> + // Load layout const layout = NUXT.layout || 'default' await _app.loadLayout(layout) _app.setLayout(layout) + <% } %> // Mounts Vue app to DOM element const mount = () => { diff --git a/test/spa.test.js b/test/spa.test.js index 72e9d65eed..5c89378ce5 100755 --- a/test/spa.test.js +++ b/test/spa.test.js @@ -8,8 +8,9 @@ const url = (route) => 'http://localhost:' + port + route const renderRoute = async _url => { const window = await nuxt.renderAndGetWindow(url(_url)) + const head = window.document.head.innerHTML const html = window.document.body.innerHTML - return { window, html } + return { window, head, html } } // Init nuxt.js and create server listening on localhost:4000 @@ -29,6 +30,11 @@ test('/custom (custom layout)', async t => { t.true(html.includes('Custom layout')) }) +test('/custom (not default layout)', async t => { + const { head } = await renderRoute('/custom') + t.false(head.includes('src="/_nuxt/layouts/default.')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close()