Next.js Discord

Discord Forum

Nextjs 15.1.4 does not work disabling hash in components and styles

Unanswered
Ivory-billed Woodpecker posted this in #help-forum
Open in Discord
Ivory-billed WoodpeckerOP
I'm using nextjs 15.1.4, I would like it not to generate elements and styles with hash, keeping only the class names.

And if possible, add to use inline css, as I'm trying to avoid css critical render blocking problem

next.config.js
//Doesn't work
cssLoader.options.modules.getLocalIdent = (context, _, localName) => localName


//Doesn't work
cssLoader.options.modules.localIdentName = '[local]'


//Doesn't work
sassOptions: {
includePaths: [path.join(__dirname, 'src/styles')],
additionalData: ` @import "src/styles/globals.scss"; `,
silenceDeprecations: ['legacy-js-api'],
localIdentName: '[local]'
}


//in nextjs 14 this works

config.module.rules.forEach((rule) => {
        if (Array.isArray(rule.oneOf)) {
          rule.oneOf.forEach((loader) => {
            if (String(loader.test) === String(/\.module\.(scss|sass)$/)) {
              const cssLoader = loader.use.find((l) => l.loader.includes('css-loader'))
              const sassLoader = loader.use.find((l) => l.loader.includes('sass-loader'))

              if (cssLoader && cssLoader?.options?.modules?.getLocalIdent) {
                cssLoader.options.modules.getLocalIdent = (context, _, localName) => localName
              }

              if (sassLoader) {
                sassLoader.options = {
                  ...sassLoader.options,
                  additionalData: ' @import "src/styles/globals.scss"; '
                }
              }
            }
          })
        }
      })

0 Replies