I am in a react project, compiled using webpack, and using less.
The root of the application imports a top-level styles.less which imports variables.less which defines a bunch of LESS variables.
There is also a directory components which has a number of folders, each folder has a styles.less and an index.jsx which imports it.
At the moment, if I try to access variables from the components (e.g. Card/styles.less) I get a 'Variable [x] is undefined` error.
Is there a way I can make these variables 'globally accessible' to all the less in the project?
Versions:
- React 16.7
- webpack 4.28
- babel 7.5
- less 3.9
- less-loader 5.0
webpack config
module: {
rules: [
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
modifyVars: { // this modifies the antd variables
'primary-color': '#5c31a8',
'border-radius-base': '2px'
},
javascriptEnabled: true
}
}
]
}
]
},