Move store hydration after plugins execution

This commit is contained in:
Sebastien Chopin 2017-08-22 11:08:59 +02:00
parent b931dd40ce
commit 8dca358216

View File

@ -47,15 +47,6 @@ async function createApp (ssrContext) {
}) })
} }
<% if (store) { %>
if (process.browser) {
// Replace store state before calling plugins
if (window.__NUXT__ && window.__NUXT__.state) {
store.replaceState(window.__NUXT__.state)
}
}
<% } %>
// Create Root instance // Create Root instance
// here we inject the router and store to all child components, // here we inject the router and store to all child components,
// making them available everywhere as `this.$router` and `this.$store`. // making them available everywhere as `this.$router` and `this.$store`.
@ -123,6 +114,15 @@ async function createApp (ssrContext) {
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx)<% }) %> if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx)<% }) %>
}<% } %> }<% } %>
<% if (store) { %>
if (process.browser) {
// Replace store state before calling plugins
if (window.__NUXT__ && window.__NUXT__.state) {
store.replaceState(window.__NUXT__.state)
}
}
<% } %>
return { return {
app, app,
router, router,