Created
October 18, 2018 10:43
-
-
Save jinseokoh/a0eaf55b234b3123c22b1db4be8f0f43 to your computer and use it in GitHub Desktop.
laravel-vue-spa-blog-02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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