2022-09-20 19:59:52 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
// Load store modules dynamically.
|
2023-01-21 11:57:37 +00:00
|
|
|
const requireContext = import.meta.glob('./modules/**/*.js', {eager: true})
|
2022-09-20 19:59:52 +00:00
|
|
|
|
2023-01-21 11:57:37 +00:00
|
|
|
const modules = Object.keys(requireContext)
|
2022-09-20 19:59:52 +00:00
|
|
|
.map(file =>
|
2023-01-21 11:57:37 +00:00
|
|
|
[file.replace(/(^.\/)|(\.js$)/g, '').replace('modules/',''), requireContext[file]]
|
2022-09-20 19:59:52 +00:00
|
|
|
)
|
|
|
|
.reduce((modules, [name, module]) => {
|
|
|
|
if (module.namespaced === undefined) {
|
2023-01-21 11:57:37 +00:00
|
|
|
module = {...module, namespaced: true}
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return { ...modules, [name]: module }
|
|
|
|
}, {})
|
|
|
|
|
|
|
|
export default new Vuex.Store({
|
|
|
|
modules
|
|
|
|
})
|