Skip to content

Instantly share code, notes, and snippets.

@linhtranvu

linhtranvu/index.js

Created Aug 15, 2019
Embed
What would you like to do?
store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
// import example from './module-example'
import hoso from './hoso'
import tree from './tree'
Vue.use(Vuex)
/*
* If not building with SSR mode, you can
* directly export the Store instantiation
*/
const Store = new Vuex.Store({
modules: {
// example
hoso,
tree
},
plugins: [createPersistedState()],
// enable strict mode (adds overhead!)
// for dev mode only
strict: process.env.DEV
})
export default function ( /* { ssrContext } */ ) {
/*
if we want some HMR magic for it, we handle
the hot update like below. Notice we guard this
code with "process.env.DEV" -- so this doesn't
get into our production build (and it shouldn't).
*/
if (process.env.DEV && module.hot) {
module.hot.accept(['./hoso'], () => {
const newShowcase = require('./hoso').default
Store.hotUpdate({
modules: {
showcase: newHoso
}
})
}),
module.hot.accept(['./tree'], () => {
const newShowcase = require('./tree').default
Store.hotUpdate({
modules: {
tree: newTree
}
})
})
}
return Store
}
export {
Store
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.