问题
项目背景:vue3+js
尝试npm install -g sass命令全局安装sass也无济于事.
解决
在vite.config.js文件添加配置即可解决.
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/styles/common.scss";`,
}
}
}
common.scss文件内容:
html,
body,
ul {
margin: 0;
padding: 0;
}
html {
scroll-behavior: smooth;
}
a {
text-decoration: none;
outline: none;
}
ul {
list-style-type: none;
}
p,h1,h2,h3,h4,h5,h6{
margin: 0;
}
@mixin pageFont($fs, $c, $fw, $fa, $lh) {
font-size: $fs;
font-family: $fa;
font-weight: $fw;
color: $c;
line-height: $lh;
}