admin管理员组文章数量:1026373
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?
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?
本文标签:
版权声明:本文标题:reactjs - How to fix `[plugin:vite:css] [less] <css class> is undefined` error when apply less preprocessors? - St 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745648760a2161186.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论