mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
import SSR plugins
This supports proper functionality of plugins registering Vue Components. Also we await for each plugin to make sure that they are initialized before createApp
This commit is contained in:
parent
eaee5afbde
commit
bbd2eddb40
@ -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: <nuxt-child>
|
||||
Vue.component(NuxtChild.name, NuxtChild)
|
||||
// Component: <nuxt-link>
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
<% }
|
||||
|
Loading…
Reference in New Issue
Block a user