'Unknown Word: 0 with webpack 5 Minimizer Plugin

I have an issue where builds suddenly started to break with the following error:

    static/css/main.b77a6a014a5ffc517c02.css from Css Minimizer plugin
    static/css/main.b77a6a014a5ffc517c02.css:2038:26: Unknown word [<no source>:1,0][static/css/main.b77a6a014a5ffc517c02.css:2038,26]

I've done a check to make sure nothing has changed in the webpack [5] config and and packages and they are the same. Not many issues around and most of the point to the order of loaders which seems correct. I've been able to narrow this down to the minification being switched on/off but nothing beyond that. Relevant minification config:

optimization: {
      minimize: isEnvProduction,
      minimizer: [
        new TerserPlugin({
          terserOptions: {
            parse: {
              ecma: 8,
            },
            compress: {
              ecma: 5,
              warnings: false,
              comparisons: false,
              inline: 2,
            },
            mangle: {
              safari10: true,
            },
            keep_classnames: true, //isEnvProductionProfile,
            keep_fnames: isEnvProductionProfile,
            output: {
              ecma: 5,
              comments: false,
              ascii_only: true,
            },
          },
        }),
        new CssMinimizerPlugin(),
      ],
      splitChunks: {
        chunks: "all",
        name: isEnvDevelopment ? "chunkyboi" : false,
      },
      runtimeChunk: {
        name: (entrypoint) => `runtime-${entrypoint.name}`,
      },
    },

The config is effectively just the ejected create-react-app with some minor modifications that were working for a very long time.

Any help would be mucho appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source