Skip to content

Commit

Permalink
Combine optimizeAssets and processAssets hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
cascornelissen committed Jun 23, 2022
1 parent cda8566 commit 65a3176
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ module.exports = class SVGSpritemapPlugin {
})

// Optimize spritemap SVG/filename
compilation.hooks.optimizeAssets.tap(plugin, (assets) => {
compilation.hooks.processAssets.tap({
name: this.constructor.name,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
}, (assets) => {
const { output: outputOptions, sprite: spriteOptions } = this.options;
const asset = compilation.getAsset(this.filenames.spritemap);

Expand Down Expand Up @@ -175,12 +178,7 @@ module.exports = class SVGSpritemapPlugin {
compilation.updateAsset(this.filenames.spritemap, new RawSource(output.data), {
minimized: true
});
});

compilation.hooks.processAssets.tap({
name: this.constructor.name,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
}, () => {
compilation.chunks.forEach((chunk) => {
if ( chunk.name !== outputOptions.chunk.name ) {
return;
Expand Down

0 comments on commit 65a3176

Please sign in to comment.