Next.js 12 import less file error
tigressbailey opened this issue · 3 comments
tigressbailey commented
After updated to Next.js 12
import styles from './Container.module.less'
will report an error:
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
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
I got it working with this config:
cssLoaderOptions: {
modules: {
getLocalIdent: (_context, _localIdentName, localName) => localName,
},
lessVarsFilePath: './styles/variable.less',
// ...
}