Skip to content

Commit

Permalink
Add images to exclude instead of removing webpack rule
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilwanner committed Apr 11, 2020
1 parent c39c44d commit e5f656e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,16 @@ const withOptimizedImages = (nextConfig = {}, nextComposePlugins = {}) => {
if (enrichedConfig.module.rules) {
enrichedConfig.module.rules.forEach((rule) => {
if (rule.oneOf) {
// eslint-disable-next-line no-param-reassign
rule.oneOf = rule.oneOf.map((subRule) => {
rule.oneOf.forEach((subRule) => {
if (
subRule.issuer && !subRule.test && !subRule.include && subRule.exclude
&& subRule.use && subRule.use.options && subRule.use.options.name
) {
if (String(subRule.issuer.test) === '/\\.(css|scss|sass)$/' && subRule.use.options.name.startsWith('static/media/')) {
return null;
subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/);
}
}

return subRule;
}).filter(Boolean);
});
}
});
}
Expand Down

0 comments on commit e5f656e

Please sign in to comment.