SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

Next.js 12 import less file error #88

Closed tigressbailey closed 2 years ago

tigressbailey commented 2 years ago

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
        },
      }),
kulesa commented 2 years ago

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',
 // ...
}
kulesa commented 2 years ago

I got it working with this config:

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

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