我想使用导入程序编译SCSS文件。
我的代码不起作用:
var sassFilesMatchPatterns = [
'styles/default/components/badge/_settings.scss',
'styles/default/components/badge/_badge.scss'
]
var sass = require('node-sass');
sassFilesMatchPatterns.forEach(function (file) {
sass.render({
file: file
}, function(err, result) {
if (err) {
console.log(err + '\r\n' + JSON.stringify(result) + file);
}
});
});
// _badge.scss
.badge {
background-color: $badge-bg;
color: text-contrast($badge-bg);
padding: 0 15px;
line-height: $badge-height;
height: $badge-height;
border-radius: 10px;
display: inline-block;
box-shadow: 0 0 5px gray;
}
// _settings.scss
$black: #000;
$white: #fff;
$badge-bg: $main-color;
$badge-height: 22px;
问题:
Error: Undefined variable: "$badge-bg".
nullstyles/default/components/badge/_badge.scss
答案 0 :(得分:0)
你需要使用rhe" @import setitings"在badges.scss的顶部我从你那里引用变量