diff --git a/lib/app/index.js b/lib/app/index.js index b3a45134a4..9e80d20401 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -12,6 +12,11 @@ import App from '<%= appPath %>' import { getContext } from './utils' +// Import SSR plugins +<% plugins.forEach(function (plugin) { if (plugin.ssr) +{ %>import <%= plugin.name %> from '<%= r(plugin.src) %>' +<% }}) %> + // Component: Vue.component(NuxtChild.name, NuxtChild) // Component: @@ -113,20 +118,18 @@ async function createApp (ssrContext) { delete ctx.redirect delete ctx.error - // Includes & Inject external plugins + // Inject external plugins <% plugins.forEach(function (plugin) { if (plugin.ssr) { %> - let <%= plugin.name %> = require('<%= plugin.src %>') - <%= plugin.name %> = <%= plugin.name %>.default || <%= plugin.name %> if (typeof <%= plugin.name %> === 'function') { - <%= plugin.name %>(ctx) + await <%= plugin.name %>(ctx) } <% } else { %> if (process.browser) { let <%= plugin.name %> = require('<%= plugin.src %>') <%= plugin.name %> = <%= plugin.name %>.default || <%= plugin.name %> if (typeof <%= plugin.name %> === 'function') { - <%= plugin.name %>(ctx) + await <%= plugin.name %>(ctx) } } <% }