File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
configCases/asset-modules/allow-numeric-only-hash Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -1374,6 +1374,19 @@ Object {
1374
1374
" multiple" : false ,
1375
1375
" simpleType" : " string" ,
1376
1376
},
1377
+ " module-generator-asset-resource-allow-numeric-only-hash" : Object {
1378
+ " configs" : Array [
1379
+ Object {
1380
+ " description" : " Hash may not contain any non-numeric characters when true. Hash may prefixed with character 'a' when false." ,
1381
+ " multiple" : false ,
1382
+ " path" : " module.generator.asset/resource.allowNumericOnlyHash" ,
1383
+ " type" : " boolean" ,
1384
+ },
1385
+ ],
1386
+ " description" : " Hash may not contain any non-numeric characters when true. Hash may prefixed with character 'a' when false." ,
1387
+ " multiple" : false ,
1388
+ " simpleType" : " boolean" ,
1389
+ },
1377
1390
" module-generator-asset-resource-emit" : Object {
1378
1391
" configs" : Array [
1379
1392
Object {
Original file line number Diff line number Diff line change
1
+ import url from "../_images/file.png" ;
2
+ import url2 from "../_images/file_copy.png" ;
3
+
4
+ it ( "should import asset with module.generator.asset.allowNumericOnlyHash" , ( ) => {
5
+ expect ( url ) . toMatch ( / i m a g e s \/ f i l e \. [ a - f 0 - 9 ] { 6 } \. p n g $ / ) ;
6
+ expect ( url2 ) . toMatch ( / i m a g e s \/ f i l e _ c o p y \. [ a - f 0 - 9 ] { 6 } \. p n g $ / ) ;
7
+ const assetInfo1 = __STATS__ . assets . find (
8
+ a => a . info . sourceFilename === "../_images/file.png"
9
+ ) . info ;
10
+ const assetInfo2 = __STATS__ . assets . find (
11
+ a => a . info . sourceFilename === "../_images/file_copy.png"
12
+ ) . info ;
13
+
14
+ expect ( assetInfo1 . contenthash . length ) . toBe ( 2 ) ;
15
+ expect ( assetInfo1 . contenthash [ 0 ] . length ) . toBe ( 6 ) ;
16
+ expect ( assetInfo1 . contenthash [ 1 ] . length ) . toBe ( 6 ) ;
17
+ expect ( assetInfo2 . contenthash . length ) . toBe ( 2 ) ;
18
+ expect ( assetInfo2 . contenthash [ 0 ] . length ) . toBe ( 6 ) ;
19
+ expect ( assetInfo2 . contenthash [ 1 ] . length ) . toBe ( 6 ) ;
20
+
21
+ expect ( assetInfo1 . fullhash ) . toBe ( assetInfo2 . fullhash ) ;
22
+ expect ( assetInfo1 . contenthash [ 0 ] ) . not . toEqual ( assetInfo2 . contenthash [ 0 ] ) ;
23
+ expect ( assetInfo1 . contenthash [ 0 ] . slice ( 1 ) ) . toEqual ( assetInfo2 . contenthash [ 0 ] . slice ( 1 ) ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /** @type {import("../../../../").Configuration } */
2
+ module . exports = {
3
+ mode : "development" ,
4
+ output : {
5
+ hashDigestLength : 6
6
+ } ,
7
+ module : {
8
+ rules : [
9
+ {
10
+ test : / f i l e .p n g $ / ,
11
+ type : "asset/resource" ,
12
+ generator : {
13
+ emit : false ,
14
+ filename : "[name].[contenthash:6][ext]" ,
15
+ allowNumericOnlyHash : false
16
+ }
17
+ } ,
18
+ {
19
+ test : / f i l e _ c o p y .p n g $ / ,
20
+ type : "asset/resource" ,
21
+ generator : {
22
+ emit : false ,
23
+ filename : "[name].[contenthash:6][ext]" ,
24
+ allowNumericOnlyHash : true
25
+ }
26
+ }
27
+ ]
28
+ }
29
+ } ;
You can’t perform that action at this time.
0 commit comments