Skip to content

Commit

Permalink
Merge pull request #53 from drolsen/dev
Browse files Browse the repository at this point in the history
2.2.22 Dev Release
  • Loading branch information
drolsen authored Oct 22, 2024
2 parents fb0f7db + a9f4f3d commit c874b7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ class WebpackSvgSpritely {

apply(compiler) {
compiler.hooks.thisCompilation.tap({ name: 'WebpackSvgSpritely' }, (compilation) => {
/* Ensures no memory leaks */
process.spritely.symbols = [];
process.spritely.manifest = [];

/* Gather SVG Symbols & Optional Manifest Data */
compilation.hooks.chunkAsset.tap('WebpackSvgSpritely', (chunk, filename) => {
const assets = compilation.getAssets();
Expand All @@ -219,10 +223,6 @@ class WebpackSvgSpritely {
const source = asset.source.source().toString('utf8');
const { name } = asset;

asset.symbol = cleanSymbolContents(name, this.options.prefix, source);
asset.entry = entryFiles.find((entryFile) => chunk.name === entryFile || filename.includes(entryFile));

process.spritely.manifest.push({name, source});

let hasNoDuplicate = true;
Object.keys(process.spritely.symbols).map((j) => {
Expand All @@ -232,6 +232,9 @@ class WebpackSvgSpritely {
});

if (hasNoDuplicate) {
asset.symbol = cleanSymbolContents(name, this.options.prefix, source);
asset.entry = entryFiles.find((entryFile) => chunk.name === entryFile || filename.includes(entryFile));
process.spritely.manifest.push({name, source});
process.spritely.symbols.push(asset);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"webpack svg sprite",
"webpack svg sprite plugin"
],
"version": "2.2.21",
"version": "2.2.22",
"description": "Plugin that bundles project SVG files into a SVG sprite",
"repository": "drolsen/webpack-svg-spritely",
"bugs": {
Expand Down

0 comments on commit c874b7a

Please sign in to comment.