Skip to content

Instantly share code, notes, and snippets.

@kadikraman
Last active June 22, 2017 10:01
Show Gist options
  • Select an option

  • Save kadikraman/47eb395cc3501b3823900ae8179ef419 to your computer and use it in GitHub Desktop.

Select an option

Save kadikraman/47eb395cc3501b3823900ae8179ef419 to your computer and use it in GitHub Desktop.
(Webpack) require a bunch of files based on a regex
/*
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