Skip to content

Commit d5cd482

Browse files
committed
Use [hash:8] for images and fonts filenames instead of [hash]
1 parent 874235d commit d5cd482

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

lib/config-generator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ class ConfigGenerator {
127127
test: /\.(png|jpg|jpeg|gif|ico|svg)$/,
128128
loader: 'file-loader',
129129
options: {
130-
name: 'images/[name].[hash].[ext]',
130+
name: 'images/[name].[hash:8].[ext]',
131131
publicPath: this.webpackConfig.getRealPublicPath()
132132
}
133133
},
134134
{
135135
test: /\.(woff|woff2|ttf|eot|otf)$/,
136136
loader: 'file-loader',
137137
options: {
138-
name: 'fonts/[name].[hash].[ext]',
138+
name: 'fonts/[name].[hash:8].[ext]',
139139
publicPath: this.webpackConfig.getRealPublicPath()
140140
}
141141
},

test/functional.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('Functional tests using webpack', function() {
6262
'main.js',
6363
'font.css',
6464
'bg.css',
65-
'fonts/Roboto.9896f773628188b649ed5824fa363290.woff2',
66-
'images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png',
65+
'fonts/Roboto.9896f773.woff2',
66+
'images/symfony_logo.ea1ca6f7.png',
6767
'manifest.json'
6868
]);
6969

@@ -87,11 +87,11 @@ describe('Functional tests using webpack', function() {
8787
);
8888
webpackAssert.assertManifestPath(
8989
'build/fonts/Roboto.woff2',
90-
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
90+
'/build/fonts/Roboto.9896f773.woff2'
9191
);
9292
webpackAssert.assertManifestPath(
9393
'build/images/symfony_logo.png',
94-
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
94+
'/build/images/symfony_logo.ea1ca6f7.png'
9595
);
9696

9797
done();
@@ -119,11 +119,11 @@ describe('Functional tests using webpack', function() {
119119

120120
webpackAssert.assertOutputFileContains(
121121
'bg.css',
122-
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
122+
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7.png'
123123
);
124124
webpackAssert.assertOutputFileContains(
125125
'font.css',
126-
'http://localhost:8090/assets/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
126+
'http://localhost:8090/assets/fonts/Roboto.9896f773.woff2'
127127
);
128128
// manifest file has CDN in value
129129
webpackAssert.assertManifestPath(
@@ -172,7 +172,7 @@ describe('Functional tests using webpack', function() {
172172

173173
webpackAssert.assertOutputFileContains(
174174
'bg.css',
175-
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
175+
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7.png'
176176
);
177177
// manifest file has CDN in value
178178
webpackAssert.assertManifestPath(
@@ -285,20 +285,20 @@ describe('Functional tests using webpack', function() {
285285
'0.d002be21e9bcf76057e9.js', // chunks are also versioned
286286
'main.292c0347ed1240663cb1.js',
287287
'h1.c84caea6dd12bba7955dee9fedd5fd03.css',
288-
'bg.42ced8eae2254268bb3c65f1e65bd041.css',
288+
'bg.483832e48e67e6a3b7f0ae064eadca51.css',
289289
'manifest.json'
290290
]
291291
);
292292

293293
expect(path.join(config.outputPath, 'images')).to.be.a.directory()
294294
.with.files([
295-
'symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
295+
'symfony_logo.ea1ca6f7.png'
296296
]
297297
);
298298

299299
webpackAssert.assertOutputFileContains(
300-
'bg.42ced8eae2254268bb3c65f1e65bd041.css',
301-
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
300+
'bg.483832e48e67e6a3b7f0ae064eadca51.css',
301+
'/build/images/symfony_logo.ea1ca6f7.png'
302302
);
303303

304304
done();
@@ -323,24 +323,24 @@ describe('Functional tests using webpack', function() {
323323

324324
expect(path.join(config.outputPath, 'images')).to.be.a.directory()
325325
.with.files([
326-
'symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
326+
'symfony_logo.ea1ca6f7.png'
327327
]
328328
);
329329

330330
expect(path.join(config.outputPath, 'fonts')).to.be.a.directory()
331331
.with.files([
332-
'Roboto.9896f773628188b649ed5824fa363290.woff2'
332+
'Roboto.9896f773.woff2'
333333
]
334334
);
335335

336336
webpackAssert.assertOutputFileContains(
337337
'bg.css',
338-
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
338+
'/build/images/symfony_logo.ea1ca6f7.png'
339339
);
340340

341341
webpackAssert.assertOutputFileContains(
342342
'font.css',
343-
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
343+
'/build/fonts/Roboto.9896f773.woff2'
344344
);
345345

346346
done();
@@ -363,36 +363,36 @@ describe('Functional tests using webpack', function() {
363363

364364
expect(path.join(config.outputPath, 'images')).to.be.a.directory()
365365
.with.files([
366-
'symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png',
367-
'symfony_logo.f27119c20951b473f2de80c000d60fa8.png'
366+
'symfony_logo.ea1ca6f7.png',
367+
'symfony_logo.f27119c2.png'
368368
]
369369
);
370370

371371
expect(path.join(config.outputPath, 'fonts')).to.be.a.directory()
372372
.with.files([
373-
'Roboto.9896f773628188b649ed5824fa363290.woff2',
374-
'Roboto.3c37aa69cd77e6a53a067170fa8fe2e9.woff2'
373+
'Roboto.9896f773.woff2',
374+
'Roboto.3c37aa69.woff2'
375375
]
376376
);
377377

378378
webpackAssert.assertOutputFileContains(
379379
'styles.css',
380-
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
380+
'/build/images/symfony_logo.ea1ca6f7.png'
381381
);
382382

383383
webpackAssert.assertOutputFileContains(
384384
'styles.css',
385-
'/build/images/symfony_logo.f27119c20951b473f2de80c000d60fa8.png'
385+
'/build/images/symfony_logo.f27119c2.png'
386386
);
387387

388388
webpackAssert.assertOutputFileContains(
389389
'styles.css',
390-
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
390+
'/build/fonts/Roboto.9896f773.woff2'
391391
);
392392

393393
webpackAssert.assertOutputFileContains(
394394
'styles.css',
395-
'/build/fonts/Roboto.3c37aa69cd77e6a53a067170fa8fe2e9.woff2'
395+
'/build/fonts/Roboto.3c37aa69.woff2'
396396
);
397397

398398
done();
@@ -735,7 +735,7 @@ module.exports = {
735735
expect(config.outputPath).to.be.a.directory().with.deep.files([
736736
'main.js',
737737
'main.css',
738-
'images/logo.82b9c7a5a3f405032b1db71a25f67021.png',
738+
'images/logo.82b9c7a5.png',
739739
'manifest.json'
740740
]);
741741

0 commit comments

Comments
 (0)