SolidZORO/next-plugin-antd-less

Next.js 12 import less file error

tigressbailey opened this issue · 3 comments

After updated to Next.js 12
import styles from './Container.module.less' will report an error:

Screen Shot 2021-10-28 at 11 52 04 AM

Config is:

 ...withAntdLess({
        // optional
        lessVarsFilePath: './styles/variable.less',
        // optional
        lessVarsFilePathAppendToEndOfContent: true,
        lessLoaderOptions: {
          lessOptions: {
            javascriptEnabled: true,
            math: 'always',
          },
        },

        // Other Config Here...
        webpack(config, options) {
          return config
        },
      }),

You can fix this by defining getLocalIdent function in config (although, I'm not sure about the return value):

cssLoaderOptions: {
  modules: {
     getLocalIdent: (_context, _localIdentName, _localName, _options) => "",
  },
 lessVarsFilePath: './styles/variable.less',
 // ...
}

I got it working with this config:

cssLoaderOptions: {
  modules: {
     getLocalIdent: (_context, _localIdentName, localName) => localName,
  },
 lessVarsFilePath: './styles/variable.less',
 // ...
}

I just updated 1.5.1 to be compatible with Next.js 12. more see CHANGELOG.