webpack与vite批量导入异同
webpack
let modules = require.context('./modules', false, /\.ts$/),
modules.keys().forEach((key) => {
let item = files(key).default
console.log(item)
})
vite
let modules = import.meta.globEager('./modules/*.ts')
Object.keys(modules).forEach((key) => {
let item = files[key].default
console.log(item)
})