File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ This is a new major version that contains several backwards-compatibility breaks
8
8
9
9
* #1344 Add options configuration callback to ` Encore.enableReactPreset() ` (@Kocal )
10
10
11
+ * #1345 Add support for integrity hashes when asset names contain a query string (@Kocal )
12
+
11
13
### BC Breaks
12
14
13
15
* #1321 Drop support of Node.js 19 and 21 (@Kocal )
Original file line number Diff line number Diff line change @@ -95,13 +95,16 @@ class EntryPointsPlugin {
95
95
for ( const entryName in manifest . entrypoints ) {
96
96
for ( const fileType in manifest . entrypoints [ entryName ] ) {
97
97
for ( const asset of manifest . entrypoints [ entryName ] [ fileType ] ) {
98
- if ( asset in manifest . integrity ) {
98
+ // Drop query string if any
99
+ let assetNormalized = asset . includes ( '?' ) ? asset . split ( '?' ) [ 0 ] : asset ;
100
+
101
+ if ( assetNormalized in manifest . integrity ) {
99
102
continue ;
100
103
}
101
104
102
- const filePath = path . resolve (
105
+ let filePath = path . resolve (
103
106
this . outputPath ,
104
- asset . replace ( this . publicPath , '' ) ,
107
+ assetNormalized . replace ( this . publicPath , '' ) ,
105
108
) ;
106
109
107
110
if ( fs . existsSync ( filePath ) ) {
@@ -115,7 +118,7 @@ class EntryPointsPlugin {
115
118
fileHashes . push ( `${ algorithm } -${ hash . digest ( 'base64' ) } ` ) ;
116
119
}
117
120
118
- manifest . integrity [ asset ] = fileHashes . join ( ' ' ) ;
121
+ manifest . integrity [ assetNormalized ] = fileHashes . join ( ' ' ) ;
119
122
}
120
123
}
121
124
}
Original file line number Diff line number Diff line change @@ -3123,6 +3123,35 @@ module.exports = {
3123
3123
done ( ) ;
3124
3124
} ) ;
3125
3125
} ) ;
3126
+
3127
+ it ( 'With query string versioning' , ( done ) => {
3128
+ const config = createWebpackConfig ( 'web/build' , 'dev' ) ;
3129
+ config . addEntry ( 'main' , './js/no_require' ) ;
3130
+ config . setPublicPath ( '/build' ) ;
3131
+ config . addStyleEntry ( 'styles' , './css/h1_style.css' ) ;
3132
+ config . enableVersioning ( true ) ;
3133
+ config . configureFilenames ( {
3134
+ js : '[name].js?v=[contenthash:16]' ,
3135
+ css : '[name].css?v=[contenthash:16]'
3136
+ } ) ;
3137
+ config . enableIntegrityHashes ( ) ;
3138
+
3139
+ testSetup . runWebpack ( config , ( webpackAssert ) => {
3140
+ const integrityData = getIntegrityData ( config ) ;
3141
+ const expectedFilesWithHashes = [
3142
+ '/build/runtime.js' ,
3143
+ '/build/main.js' ,
3144
+ '/build/styles.css' ,
3145
+ ] ;
3146
+
3147
+ expectedFilesWithHashes . forEach ( ( file ) => {
3148
+ expect ( integrityData [ file ] ) . to . contain ( 'sha384-' ) ;
3149
+ expect ( integrityData [ file ] ) . to . have . length ( 71 ) ;
3150
+ } ) ;
3151
+
3152
+ done ( ) ;
3153
+ } ) ;
3154
+ } ) ;
3126
3155
} ) ;
3127
3156
} ) ;
3128
3157
} ) ;
You can’t perform that action at this time.
0 commit comments