Vite处理css postcss import variable less
作者:互联网
支持css3 variables
src/styles/index.css
/* css3 variable */
:root{
--main-font-color: blue
}
#app{
font-size: 20px;
color: var(--main-font-color);
}
main.js
import { createApp } from 'vue'
import App from './App.vue'
import './styles/index.css'
createApp(App).mount('#app')
支持postcss
/* css3 variable */
:root{
--main-font-color: blue
}
#app{
font-size: 20px;
@console.log hello postcss;
color: var(--main-font-color);
}
"dependencies": {
"@postcss-plugins/console": "^0.2.4",
}
postcss.config.js
module.exports = {
plugins:[require('@postcss-plugins/console')]
}
css import
@import url(./other.css);
div{}
css-modules
定义 test.module.css
.moduleClass{
color: lightgreen;
}
使用
import { defineComponent } from "vue";
import classes from "@styles/test.module.css"
export default defineComponent({
setup() {
return () => <div className={`${classes.moduleClass}`}>vite app jsx</div>
}
})
css-processor scss/less
安装依赖
yarn add less
test.less
@bgColor:red;
.lessBox{
color: @bgColor;
}
App.jsx
import { defineComponent } from "vue";
import classes from "@styles/test.module.css"
import '@styles/test.less'
export default defineComponent({
setup() {
return () => <div className={`${classes.moduleClass}`}>vite app jsx <div className="lessBox">less box</div></div>
}
})
标签:less,color,Vite,variable,import,font,postcss,css 来源: https://www.cnblogs.com/ltfxy/p/16345257.html