背景
- 第1次使用sass
- 第1次配置gruntfile.js
问题
通过grunt
自动编译sass
文件为css
文件,总是报错
为什么要报错呢?
$ grunt
Running "sass:dist" (sass) task
Error: Invalid CSS after ".test ": expected selector, was "{color:red;}"
on line 1 of test.sass
Use --trace for backtrace.
Warning: Exited with error code 13 Use --force to continue.
Aborted due to warnings.
代码
Gruntfile.js
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.initConfig({
sass: {
dist: {
files: {
'test.css':'test.sass'
}
}
}
});
grunt.registerTask('default',['sass']);
}
test.sass
.test {
color:red;
}
解决
把test.sass
修改成test.scss
就行了
原因
sass
和scss
的语法不一样
花括号{}
和分号 ;
是scss
里面的语法
解决
把test.sass修改成test.scss就行了
原因
sass和scss的语法不一样
花括号{}和分号 ;是scss里面的语法
参考
http://sass.bootcss.com/docs/...