Skip to content

Instantly share code, notes, and snippets.

@jinseokoh
Created October 18, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jinseokoh/a0eaf55b234b3123c22b1db4be8f0f43 to your computer and use it in GitHub Desktop.
Save jinseokoh/a0eaf55b234b3123c22b1db4be8f0f43 to your computer and use it in GitHub Desktop.
laravel-vue-spa-blog-02
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
// Load store modules dynamically.
const requireContext = require.context('./modules', false, /.*\.js$/)
const modules = requireContext.keys()
.map(file =>
[file.replace(/(^.\/)|(\.js$)/g, ''), requireContext(file)]
)
.reduce((modules, [name, module]) => {
if (module.namespaced === undefined) {
module.namespaced = true
}
return { ...modules, [name]: module }
}, {})
export default new Vuex.Store({
modules
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment