Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AubreyF/00462643d8c75128642d2221b2393bab to your computer and use it in GitHub Desktop.
Save AubreyF/00462643d8c75128642d2221b2393bab to your computer and use it in GitHub Desktop.
Incorporate all images from folder into webpack build
// Incorporate dynamically-referenced product and interface reference images into the build
export const resourceRefs = require.context(
'./resources',
false,
/\.(png|jpe?g)$/,
);
export const ImageResource = {};
// eslint-disable-next-line no-return-assign
resourceRefs
.keys()
.map((item) => (ImageResource[item.replace('./', '')] = resourceRefs(item)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment