@@ -320,20 +320,26 @@ class ConfigGenerator {
320
320
* * https://github.com/webpack/webpack.js.org/issues/652#issuecomment-273324529
321
321
* * https://webpack.js.org/guides/caching/#deterministic-hashes
322
322
*/
323
- // when not using versioning, none of this is important
324
- if ( this . webpackConfig . useVersioning ) {
325
- let moduleNamePlugin ;
326
- if ( this . webpackConfig . isProduction ( ) ) {
323
+ let moduleNamePlugin ;
324
+ if ( this . webpackConfig . isProduction ( ) ) {
325
+ // only enable if versioning is on, as it makes the assets *slightly* larger
326
+ if ( this . webpackConfig . useVersioning ) {
327
327
// shorter, and obfuscated module ids
328
328
moduleNamePlugin = new webpack . HashedModuleIdsPlugin ( ) ;
329
- } else {
330
- // human-readable module names, helps debug in HMR
331
- moduleNamePlugin = new webpack . NamedModulesPlugin ( ) ;
332
329
}
333
- plugins = plugins . concat ( [
334
- moduleNamePlugin ,
335
- new WebpackChunkHash ( )
336
- ] ) ;
330
+ } else {
331
+ // human-readable module names, helps debug in HMR
332
+ // enable always when ! production for consistency
333
+ moduleNamePlugin = new webpack . NamedModulesPlugin ( ) ;
334
+ }
335
+
336
+ if ( moduleNamePlugin ) {
337
+ plugins = plugins . push ( moduleNamePlugin ) ;
338
+ }
339
+
340
+ if ( this . webpackConfig . useVersioning ) {
341
+ // enables the [chunkhash] ability
342
+ plugins . push ( new WebpackChunkHash ( ) ) ;
337
343
}
338
344
339
345
if ( Object . keys ( this . webpackConfig . providedVariables ) . length > 0 ) {
0 commit comments