Skip to content

Instantly share code, notes, and snippets.

@yosevu
Created May 28, 2018 20:18
Show Gist options
  • Select an option

  • Save yosevu/0441c32ec4585920b6e25121c4ac30ed to your computer and use it in GitHub Desktop.

Select an option

Save yosevu/0441c32ec4585920b6e25121c4ac30ed to your computer and use it in GitHub Desktop.
require.context
function importAll(r) {
return r.keys().map(r);
}
const images = importAll(require.context('./', false, /\.(png|jpe?g|svg)$/));
Source: https://stackoverflow.com/questions/42118296/dynamically-import-images-from-a-directory-using-webpack/42118728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment