I am new at using less. I initialized my codebase using npm create vite@latest
. I have set the vite config as below:
css: {
preprocessorOptions: {
less: {
math: "always",
relativeUrls: true,
javascriptEnabled: true
},
},
}
Here is my directory structure:
- src/
- assets/
- css/
- commons.css
- components/
- Button.less
- Button.tsx
- App.css
- In
App.css
, I import thecommons.css
from assets folder@import "/src/assets/css/commons.css";
- In
commons.css
, I declare class.test { font-size: 100px }
- I tried to apply the
.test
class using mixins provided by Less. So inButton.less
, I use this
// @import "/src/App.css"; // I have tried to use this import to but still doesn't work.
.btn {
.test();
background-color: red;
}
If I remove the mixins, the background color will applied successfully, but after I implement the mixins, it shows error [plugin:vite:css] [less] .test is undefined
. My questions are:
- Can we import css to less?
- If yes, how to do it properly?