Skip to content

Commit 69e2cfe

Browse files
committed
Encore.configureUrlLoader() - Merge options instead of replacing them
1 parent 0ba2677 commit 69e2cfe

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/config-generator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ConfigGenerator {
159159

160160
if (this.webpackConfig.urlLoaderOptions.images) {
161161
loaderName = 'url-loader';
162-
loaderOptions = this.webpackConfig.urlLoaderOptions.images;
162+
Object.assign(loaderOptions, this.webpackConfig.urlLoaderOptions.images);
163163
}
164164

165165
rules.push({
@@ -186,7 +186,7 @@ class ConfigGenerator {
186186

187187
if (this.webpackConfig.urlLoaderOptions.fonts) {
188188
loaderName = 'url-loader';
189-
loaderOptions = this.webpackConfig.urlLoaderOptions.fonts;
189+
Object.assign(loaderOptions, this.webpackConfig.urlLoaderOptions.fonts);
190190
}
191191

192192
rules.push({

test/config-generator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ describe('The config-generator function', () => {
711711
config.outputPath = '/tmp/public-path';
712712
config.publicPath = '/public-path';
713713
config.addEntry('main', './main');
714+
config.configureFilenames({
715+
images: '[name].foo.[ext]',
716+
fonts: '[name].bar.[ext]'
717+
});
714718
config.configureUrlLoader({
715719
images: { limit: 8192 },
716720
fonts: { limit: 4096 }
@@ -720,11 +724,13 @@ describe('The config-generator function', () => {
720724

721725
const imagesRule = findRule(/\.(png|jpg|jpeg|gif|ico|svg|webp)$/, actualConfig.module.rules);
722726
expect(imagesRule.loader).to.equal('url-loader');
727+
expect(imagesRule.options.name).to.equal('[name].foo.[ext]');
723728
expect(imagesRule.options.limit).to.equal(8192);
724729

725730
const fontsRule = findRule(/\.(woff|woff2|ttf|eot|otf)$/, actualConfig.module.rules);
726731
expect(fontsRule.loader).to.equal('url-loader');
727732
expect(fontsRule.options.limit).to.equal(4096);
733+
expect(fontsRule.options.name).to.equal('[name].bar.[ext]');
728734
});
729735
});
730736

0 commit comments

Comments
 (0)