“name” option in splitChunks.chunkGroups config not honoured

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Generated filenames for chunks just have a number instead of the ‘name’ option I provide. (Regardless of whether I use true or a string.)
For example:

chunk-1.[hash].js , chunk-2.[hash].js

If the current behavior is a bug, please provide the steps to reproduce.
full configuration:
https://gist.github.com/gkatsanos/00b584f4eb9966a7632b461a6d2adc3f (base)
https://gist.github.com/gkatsanos/92f5e92ee3ef0c74fd67a28445430be0 (PRD)

This is just my optimization configuration object:

optimization: {
    minimize: false,
    runtimeChunk: 'single',
    splitChunks: {
      cacheGroups: {
        default: false,
        vendors: false,
        lodash: {
          test: /[\\/]lodash[\\/]/,
          minSize: 100,
          reuseExistingChunk: true,
          name: 'lodash',
        },
        mapjscore: {
          test: /[\\/]mapjs-core[\\/]/,
          minSize: 100,
          reuseExistingChunk: true,
          name: true,
        },
        mapsapi: {
          test: /[\\/]maps-api-for-javascript[\\/]/,
          minSize: 100,
          reuseExistingChunk: true,
          name: true,
        },
        mapsjsla: {
          test: /mapsjs-service|mapsjs-mapevents|mapsjs-clustering/,
          minSize: 100,
          reuseExistingChunk: true,
          name: true,
        },
        moment: {
          test: /[\\/]moment[\\/]/,
          reuseExistingChunk: true,
          name: true,
        },
        tracking: {
          test: /[\\/]here-tracking[\\/]/,
          reuseExistingChunk: true,
          name: true,
        },
        toolkit: {
          test: /[\\/]web-toolkit[\\/]/,
          reuseExistingChunk: true,
          name: true,
        }
      }
    },

What is the expected behavior?
To have a chunk-lodash.[hash].js etc

Author: Fantashit

1 thought on ““name” option in splitChunks.chunkGroups config not honoured

  1. You need to set optimization.namedChunks to true, since it’s not enabled by default when mode is production.

Comments are closed.