// https://webpack.js.org/guides/dependency-management/#requirecontextconstmodulesFiles=require.context('./modules',true,/\.js$/)// you do not need `import app from './modules/app'`// it will auto require all vuex module from modules fileconstmodules=modulesFiles.keys().reduce((modules,modulePath)=>{// set './app.js' => 'app'constmoduleName=modulePath.replace(/^\.\/(.*)\.\w+$/,'$1')constvalue=modulesFiles(modulePath)modules[moduleName]=value.defaultreturnmodules},{})conststore=newVuex.Store({modules,getters})exportdefaultstore