How to use the svg-sprite-loader/lib/utils.getAllModules function in svg-sprite-loader

To help you get started, we’ve selected a few svg-sprite-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github luciorubeens / pictogrify / webpack.config.js View on Github external
compilation.plugin('optimize-chunk-assets', (chunks, callback) => {
            const { assets } = compilation
            const spriteAssets = _.pickBy(assets, (value, key) => key.startsWith('sprite-'))
            if (_.isEmpty(spriteAssets) || _.isNil(spriteAssets)) throw new Error('Sprites are not compiled!')

            const spriteSources = _.transform(spriteAssets, (result, value, key) => result[key.replace(/(sprite-|.svg)/g, '')] = value.source())

            getAllModules(compilation).forEach((module) => {
              replaceInModuleSource(module, {
                __SPRITE_SOURCES__: JSON.stringify(spriteSources)