Skip to content

Commit aefb895

Browse files
authored
Merge pull request #25 from rschristian/feat/exclude-assets
feat: Exclude assets option
2 parents 15c02bb + f912646 commit aefb895

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ plugins: [
4545
| `modernize` | `boolean\|true` | Attempt to upgrade ES5 syntax to equivalent modern syntax. |
4646
| `verbose` | `boolean\|false` | Will log performance information and information about polyfills. |
4747
| `polyfillsFilename` | `string\|polyfills.legacy.js` | The name for the chunk containing polyfills for the legacy bundle. |
48+
| `exclude` | `RegExp[]\|[]` | Asset patterns that should be excluded |
4849

4950

5051
## How does this work?

src/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ const DEFAULT_OPTIONS = {
6868
/**
6969
* @default "polyfills.legacy.js"
7070
*/
71-
polyfillsFilename: 'polyfills.legacy.js'
71+
polyfillsFilename: 'polyfills.legacy.js',
72+
73+
/**
74+
* RegExp patterns of assets to exclude
75+
* @default []
76+
*/
77+
exclude: []
7278
};
7379

7480
export default class OptimizePlugin {
@@ -130,7 +136,15 @@ export default class OptimizePlugin {
130136

131137
const processing = new WeakMap();
132138
const chunkAssets = Array.from(compilation.additionalChunkAssets || []);
133-
const files = [...chunkFiles, ...chunkAssets];
139+
const files = [...chunkFiles, ...chunkAssets]
140+
.filter((asset) => {
141+
for (const pattern of this.options.exclude) {
142+
if (pattern.test(asset)) {
143+
return false;
144+
}
145+
}
146+
return true;
147+
});
134148

135149
start('Optimize Assets');
136150
let transformed;

0 commit comments

Comments
 (0)