@@ -50,8 +50,9 @@ function testHtmlPlugin (webpackConfig, expectedResults, outputFile, done, expec
50
50
expect ( compilationWarnings ) . toBe ( '' ) ;
51
51
}
52
52
if ( outputFile instanceof RegExp ) {
53
+ const fileNames = Object . keys ( stats . compilation . assets ) ;
53
54
const matches = Object . keys ( stats . compilation . assets ) . filter ( item => outputFile . test ( item ) ) ;
54
- expect ( matches . length ) . toBe ( 1 ) ;
55
+ expect ( matches [ 0 ] || fileNames ) . not . toEqual ( fileNames ) ;
55
56
outputFile = matches [ 0 ] ;
56
57
}
57
58
expect ( outputFile . indexOf ( '[hash]' ) === - 1 ) . toBe ( true ) ;
@@ -629,6 +630,22 @@ describe('HtmlWebpackPlugin', () => {
629
630
} , [ '<script src="index_bundle.js"' ] , / t e s t - \S + \. h t m l $ / , done ) ;
630
631
} ) ;
631
632
633
+ it ( 'will replace [contenthash] in the filename with a content hash of 32 hex characters' , done => {
634
+ testHtmlPlugin ( {
635
+ mode : 'production' ,
636
+ entry : {
637
+ index : path . join ( __dirname , 'fixtures/index.js' )
638
+ } ,
639
+ output : {
640
+ path : OUTPUT_DIR ,
641
+ filename : '[name]_bundle.js'
642
+ } ,
643
+ plugins : [
644
+ new HtmlWebpackPlugin ( { filename : 'index.[contenthash].html' } )
645
+ ]
646
+ } , [ ] , / i n d e x \. [ a - f 0 - 9 ] { 32 } \. h t m l / , done ) ;
647
+ } ) ;
648
+
632
649
it ( 'allows you to use an absolute output filename' , done => {
633
650
testHtmlPlugin ( {
634
651
mode : 'production' ,
@@ -1264,7 +1281,6 @@ describe('HtmlWebpackPlugin', () => {
1264
1281
} , false ,
1265
1282
shouldExpectWarnings ) ;
1266
1283
} ) ;
1267
-
1268
1284
it ( 'works with commons chunk plugin' , done => {
1269
1285
testHtmlPlugin ( {
1270
1286
mode : 'production' ,
0 commit comments