This is a craco Less & Less Modules plugin, support create-react-app version >= 3.
Then install craco-less-plugin
:
$ yarn add craco-less-plugin
Here is a complete craco.config.js
configuration file that adds Less compilation to create-react-app
:
const CracoLessPlugin = require('craco-less-plugin')
module.exports = {
plugins: [{ plugin: CracoLessPlugin }]
}
View the less-loader
documentation
For example:
const CracoLessPlugin = require('craco-less-plugin')
module.exports = {
plugins: [
{
plugin: cracoLessPlugin,
options: {
modifyVars: {
hack: `true;@import "${require.resolve('./src/theme.less')}";`
},
javascriptEnabled: true
}
}
]
}
using the [name].module.less file naming convention
For example:
Button.module.less
.button {
background-color: red;
}