Skip to content

Instantly share code, notes, and snippets.

Created October 18, 2018 10:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jinseokoh/a0eaf55b234b3123c22b1db4be8f0f43 to your computer and use it in GitHub Desktop.
import Vue from 'vue'
import Vuex from '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({
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment