I am writing a plugin which creates a SVG sprite. It globs over the directories, merge SVG files in one image and returns the result. The idea is to dynamically create a module (which contains merged images) so that other modules can require it as an usual module. Or maybe you can suggest a more elegant solution?
Config
{
plugins: [
new SvgSpritePlugin({
sprites: {
icons: 'images/svg/icons/*.svg',
logos: 'images/svg/logos/*.svg',
socials: 'images/svg/logos/{twitter,youtube,facebook}.svg',
}
})
]
}
Somewhere in the application
var logosSprite = require('sprite/logos'); // require dynamically created module
document.body.appendChild(logoSprite);