fe-drone-ci/src/store/index.js

26 lines
688 B
JavaScript
Raw Normal View History

2017-08-22 07:43:34 +00:00
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
2017-04-18 07:09:13 +00:00
2017-08-22 07:43:34 +00:00
Vue.use(Vuex)
2017-04-18 07:09:13 +00:00
// https://webpack.js.org/guides/dependency-management/#requirecontext
const modulesFiles = require.context('./modules', false, /\.js$/)
// you do not need `import app from './modules/app'`
// it will auto require all vuex module from modules file
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
// set './app.js' => 'app'
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
const value = modulesFiles(modulePath)
modules[moduleName] = value.default
return modules
}, {})
2017-04-18 07:09:13 +00:00
const store = new Vuex.Store({
modules,
2017-04-18 07:09:13 +00:00
getters
2017-08-22 07:43:34 +00:00
})
2017-04-18 07:09:13 +00:00
export default store