Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.js优化建议 #27

Open
williamqian opened this issue Apr 9, 2018 · 2 comments
Open

index.js优化建议 #27

williamqian opened this issue Apr 9, 2018 · 2 comments

Comments

@williamqian
Copy link

现在需要手动一个个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
Copy link
Owner

proYang commented Apr 11, 2018

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

@williamqian
Copy link
Author

哈哈,不客气

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants