diff --git a/lib/app/store.js b/lib/app/store.js index f9899b0e42..f3a5854949 100644 --- a/lib/app/store.js +++ b/lib/app/store.js @@ -13,7 +13,6 @@ let storeData = {} // Check if store/index.js exists if (filenames.indexOf('./index.js') !== -1) { storeData = getModule('./index.js') - storeData.state = storeData.state() // Vuex Bug! } // Store modules @@ -34,12 +33,16 @@ for (let filename of filenames) { } // createStore -export const createStore = storeData === 'function' ? storeData : () => new Vuex.Store(storeData) +export const createStore = storeData === 'function' ? storeData : () => { + return new Vuex.Store(Object.assign({}, storeData, { + state: storeData.state() // Vuex Bug! + })) +} // Dynamically require module function getModule (filename) { const file = files(filename) - const module = Object.assign({}, file.default || file) + const module = file.default || file if (module.state && typeof module.state !== 'function') { // eslint-disable-next-line no-console console.error('[nuxt] store state should be a function.')