diff --git a/lib/config-generator.js b/lib/config-generator.js index 73182609..dcabae5b 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -328,7 +328,7 @@ class ConfigGenerator { if (this.webpackConfig.imageRuleOptions.enabled) { rules.push(generateAssetRuleConfig( - /\.(png|jpg|jpeg|gif|ico|svg|webp)$/, + /\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, this.webpackConfig.imageRuleOptions, this.webpackConfig.imageRuleCallback, 'images' diff --git a/test/config-generator.js b/test/config-generator.js index 2dddc13e..15a85218 100644 --- a/test/config-generator.js +++ b/test/config-generator.js @@ -881,7 +881,7 @@ describe('The config-generator function', () => { const actualConfig = configGenerator(config); - const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, actualConfig.module.rules).oneOf[1]; + const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, actualConfig.module.rules).oneOf[1]; expect(imagesRule.type).to.equal('asset/resource'); expect(imagesRule.generator).to.eql({ filename: 'images/[name].[hash:8][ext]' }); expect(imagesRule.parser).to.eql({}); @@ -904,7 +904,7 @@ describe('The config-generator function', () => { const actualConfig = configGenerator(config); - const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, actualConfig.module.rules).oneOf[1]; + const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, actualConfig.module.rules).oneOf[1]; expect(imagesRule.type).to.equal('asset/resource'); expect(imagesRule.generator).to.eql({ filename: 'file.[hash][ext]' }); }); @@ -921,7 +921,7 @@ describe('The config-generator function', () => { const actualConfig = configGenerator(config); - const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, actualConfig.module.rules).oneOf[1]; + const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, actualConfig.module.rules).oneOf[1]; expect(imagesRule.parser).to.eql({ dataUrlCondition: { maxSize: 3000 } }); }); @@ -937,7 +937,7 @@ describe('The config-generator function', () => { const actualConfig = configGenerator(config); expect(function() { - findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, actualConfig.module.rules); + findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, actualConfig.module.rules); }).to.throw(); }); }); @@ -1229,7 +1229,7 @@ describe('The config-generator function', () => { }); const webpackConfig = configGenerator(config); - const rule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, webpackConfig.module.rules).oneOf[1]; + const rule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp|avif)$/, webpackConfig.module.rules).oneOf[1]; expect(rule.generator.filename).to.equal('dirname-images/[hash:42][ext]'); });