Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Added option for excluding named chunks #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ class PreloadPlugin {
});
}

if (Array.isArray(options.exclude)) {
// Exclude user specified chunks
extractedChunks = extractedChunks.filter(chunk => {
const chunkName = chunk.name;
// Only care about named chunks
if (!chunkName) {
return true;
}
return !options.exclude.includes(chunkName);
});
}

// only handle the chunks associated to this htmlWebpackPlugin instance, in case of multiple html plugin outputs
// allow `allAssets` mode to skip, as assets are just files to be filtered by black/whitelist, not real chunks
if (options.include !== 'allAssets') {
Expand Down Expand Up @@ -235,6 +247,18 @@ class PreloadPlugin {
});
}

if (Array.isArray(options.exclude)) {
// Exclude user specified chunks
extractedChunks = extractedChunks.filter(chunk => {
const chunkName = chunk.name;
// Only care about named chunks
if (!chunkName) {
return true;
}
return !options.exclude.includes(chunkName);
});
}

// only handle the chunks associated to this htmlWebpackPlugin instance, in case of multiple html plugin outputs
// allow `allAssets` mode to skip, as assets are just files to be filtered by black/whitelist, not real chunks
if (options.include !== 'allAssets') {
Expand Down
76 changes: 38 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.