proYang / outils

:rocket: 前端业务代码工具库
https://www.npmjs.com/package/outils
MIT License
2.61k stars 591 forks source link

index.js优化建议 #27

Open williamqian opened 6 years ago

williamqian commented 6 years ago

现在需要手动一个个require,我自己改成了自动require,代码如下,亲测没问题。

/**
 * @desc webpack打包入口文件
 */
let moduleExports = {};

const r = require.context('./', true, /^\.\/.+\/.+\.js$/);
r.keys().forEach(key => {
    let attr = key.substring(key.lastIndexOf('/') + 1, key.lastIndexOf('.'));
    moduleExports[attr] = r(key);
});

module.exports = moduleExports;
proYang commented 6 years ago

index.js 已更改为自动引入,非常感谢。:rose:

williamqian commented 6 years ago

哈哈,不客气