diff --git a/lib/app/index.js b/lib/app/index.js index 9e80d20401..a812d16426 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -12,9 +12,19 @@ import App from '<%= appPath %>' import { getContext } from './utils' +if (process.browser) { + // window.onNuxtReady(() => console.log('Ready')) hook + // Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading) + window._nuxtReadyCbs = [] + window.onNuxtReady = function (cb) { + window._nuxtReadyCbs.push(cb) + } +} + // Import SSR plugins <% plugins.forEach(function (plugin) { if (plugin.ssr) -{ %>import <%= plugin.name %> from '<%= r(plugin.src) %>' +{ %>let <%= plugin.name %> = require('<%= r(plugin.src) %>') +<%= plugin.name %> = <%= plugin.name %>.default || <%= plugin.name %> <% }}) %> // Component: @@ -58,12 +68,6 @@ async function createApp (ssrContext) { store.replaceState(window.__NUXT__.state) } <% } %> - // window.onNuxtReady(() => console.log('Ready')) hook - // Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading) - window._nuxtReadyCbs = [] - window.onNuxtReady = function (cb) { - window._nuxtReadyCbs.push(cb) - } } // root instance