Created
May 28, 2018 20:18
-
-
Save yosevu/0441c32ec4585920b6e25121c4ac30ed to your computer and use it in GitHub Desktop.
require.context
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
| 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