Open saileshkotha opened 4 years ago
I'll take a look at this later. This might be exactly what I need :-)
It's not going to work if you're trying to change a property with a variable that hasn't been defined in your antdCustom.scss
file.
For example, if you didn't define @highlight-color
in your file and you're trying to set '@label-required-color': '@highlight-color';
(even though it's defined in 'antd/dist/antd.less'
), it's going to throw an error.
The only way to to deal with the issue (and I've tried around 7-8 different approaches, including scss-to-json
, less-to-json
, this plugin and so on), is to write your styles in js file like so:
theme.js
module.exports = {
'@primary-color': '#252930',
'@dark-gray': '#a09fa0',
'@light-gray': '#f2f1f1'
}
And then in config-overrides.js
:
const theme = require('../common/assets/styles/theme')
const {
..., // your configs
addLessLoader,
} = require('customize-cra')
module.exports = override(
..., // your configs
addLessLoader({
lessOptions: {
javascriptEnabled: true,
modifyVars: theme,
},
}),
Unfortunately, with this approach (and others I've tried), you can forget about hot reloading when you change theme variables. Other than that, everything works as expected - your variables override the default ones, and the derivative variable are calculated based on your vars (meaning, you don't need to provide values for them, i.e, no need for '@primary-5': '#fff'
).
My current project is currently in Ant.d, Less, Create-react-app and uses react-app-rewired, customize-cra for custom webpack configurations.
Current config-override.js looks like this, and it works perfectly. Please tell me why I need this package?
Still trying to understand why I need this package? Please, help!