Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
fix(parser): limit check for empty assets to only <link/> and <script…
Browse files Browse the repository at this point in the history
…/> tags
  • Loading branch information
LKay committed Apr 26, 2018
1 parent 20670b7 commit 9c5e670
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@ class HtmlWebpackExcludeEmptyAssetsPlugin {

processAssets(pluginData, compilation) {
const base = JSON.parse(pluginData.plugin.assetJson)[0];
const head = pluginData.head.filter(
tag =>
!Boolean(tag.attributes) ||
!this.isEmpty(tag.attributes.src || tag.attributes.href, base, compilation)
);
const body = pluginData.body.filter(
tag =>
!Boolean(tag.attributes) ||
!this.isEmpty(tag.attributes.src || tag.attributes.href, base, compilation)
);
const filterTag = (tag) => {
return !["link", "script"].includes(tag.tagName) ||
!Boolean(tag.attributes) ||
!this.isEmpty(tag.attributes.src || tag.attributes.href, base, compilation);
};

return {
head,
body,
head: pluginData.head.filter(filterTag),
body: pluginData.body.filter(filterTag),
plugin: pluginData.plugin,
chunks: pluginData.chunks,
outputName: pluginData.outputName
Expand Down

0 comments on commit 9c5e670

Please sign in to comment.