# 使用 require.context 自动导入文件

// 图片
const files = require.context(".", false, /\.(svg|png|jpg|gif)$/);
const modules = {};

files.keys().forEach((key) => {
  if (key === "./index.js") return;
  modules[key.replace(/(\.\/|\.(svg|png|jpg|gif))/g, "")] = files(key);
});

export default modules;
// js
const files = require.context(".", false, /\.js$/);
const modules = {};

files.keys().forEach((key) => {
  if (key === "./index.js") return;
  modules[key.replace(/(\.\/|\.js)/g, "")] = files(key).default;
});

export default modules;
lastUpdate: 6/22/2020, 2:10:57 AM