@@ -96,34 +96,36 @@ export class JavaScriptOptimizerPlugin {
|
96 | 96 | } |
97 | 97 | |
98 | 98 | const scriptAsset = compilation.getAsset(assetName); |
| 99 | +// Skip assets that have already been optimized or are verbatim copies (project assets) |
| 100 | +if (!scriptAsset || scriptAsset.info.minimized || scriptAsset.info.copied) { |
| 101 | +continue; |
| 102 | +} |
99 | 103 | |
100 | | -if (scriptAsset && !scriptAsset.info.minimized) { |
101 | | -const { source: scriptAssetSource, name } = scriptAsset; |
102 | | -let cacheItem; |
103 | | - |
104 | | -if (cache) { |
105 | | -const eTag = cache.getLazyHashedEtag(scriptAssetSource); |
106 | | -cacheItem = cache.getItemCache(name, eTag); |
107 | | -const cachedOutput = await cacheItem.getPromise< |
108 | | -{ source: sources.Source } | undefined |
109 | | ->(); |
110 | | - |
111 | | -if (cachedOutput) { |
112 | | -compilation.updateAsset(name, cachedOutput.source, { |
113 | | -minimized: true, |
114 | | -}); |
115 | | -continue; |
116 | | -} |
| 104 | +const { source: scriptAssetSource, name } = scriptAsset; |
| 105 | +let cacheItem; |
| 106 | + |
| 107 | +if (cache) { |
| 108 | +const eTag = cache.getLazyHashedEtag(scriptAssetSource); |
| 109 | +cacheItem = cache.getItemCache(name, eTag); |
| 110 | +const cachedOutput = await cacheItem.getPromise< |
| 111 | +{ source: sources.Source } | undefined |
| 112 | +>(); |
| 113 | + |
| 114 | +if (cachedOutput) { |
| 115 | +compilation.updateAsset(name, cachedOutput.source, { |
| 116 | +minimized: true, |
| 117 | +}); |
| 118 | +continue; |
117 | 119 | } |
118 | | - |
119 | | -const { source, map } = scriptAssetSource.sourceAndMap(); |
120 | | -scriptsToOptimize.push({ |
121 | | -name: scriptAsset.name, |
122 | | -code: typeof source === 'string' ? source : source.toString(), |
123 | | - map, |
124 | | - cacheItem, |
125 | | -}); |
126 | 120 | } |
| 121 | + |
| 122 | +const { source, map } = scriptAssetSource.sourceAndMap(); |
| 123 | +scriptsToOptimize.push({ |
| 124 | +name: scriptAsset.name, |
| 125 | +code: typeof source === 'string' ? source : source.toString(), |
| 126 | + map, |
| 127 | + cacheItem, |
| 128 | +}); |
127 | 129 | } |
128 | 130 | |
129 | 131 | if (scriptsToOptimize.length === 0) { |
|