NextJS: How could I edit the CSS-loader's localIdentName in webpack?

Hey there,

I am trying to edit the CSS-loader localIdentName in webpack so that my classnames are hashes. This solution from https://stackoverflow.com/a/66744766 worked, but made some of the styles from my globals.css invalid:

module.exports = {
  webpack(config, { buildId, dev, isServer, defaultLoaders, webpack }) {
    config.module.rules[2].oneOf.forEach((moduleLoader, i) => {
      Array.isArray(moduleLoader.use) &&
        moduleLoader.use.forEach((l) => {
          if (
            l.loader.includes('\\css-loader') &&
            !l.loader.includes('postcss-loader')
          ) {
            const { getLocalIdent, ...others } = l.options.modules;

            l.options = {
              ...l.options,
              modules: {
                ...others,
                localIdentName: '[hash:base64:6]',
              },
            };
          }
        });
    });
    return config;
  },
};

Any better/revised solutions? Thank you!!