Last active
June 22, 2017 10:01
-
-
Save kadikraman/47eb395cc3501b3823900ae8179ef419 to your computer and use it in GitHub Desktop.
(Webpack) require a bunch of files based on a regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Instead of | |
| require('../../blah/stories.js'); | |
| require('../../blah/blah/stories.js'); | |
| ... | |
| */ | |
| const req = require.context('../', true, /stories\.js$/); | |
| function loadStories() { | |
| req.keys().forEach(req); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment