本文介绍了缩进Sass语法不适用于node-sass和gulp-sass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Libsass 2.0为libsass用户带来了缩进语法,但到目前为止,我无法使用 node-sass gulp -sass 。我有所有最新版本:



node-sass :0.93

gulp-sass :0.7.2

gulp :3.8.2



此设置编译。 scss 文件,甚至 .sass 文件,但不会编译缩进语法。有没有人成功编译缩进语法与节点sass和gulp?



gulpfile.js

  var gulp = require('gulp'); 
var sass = require('gulp-sass');

gulp.task('sass',function(){
return gulp.src('./ sites / all / themes / nsfvb / sass / screen.sass')
.pipe(sass({
includePaths:require('node-neat')。includePaths,
errLogToConsole:true
}
))
.pipe .dest('./ sites / all / themes / nsfvb / css'));
});

gulp.task('watch',function(){
gulp.watch('./ sites / all / themes / nsfvb / sass / *。sass',['sass' ]);
});

gulp.task('default',['sass','watch']);



运行默认任务时出错 / p>

错误:顶级表达式无效

解决方案

更新答案:





  sass })



过期的答案



这里:

在此处找到代码示例:

  var gulp = require('gulp'); 
var sass = require('gulp-sass');

//在终端中运行> gulp sass。
gulp.task('sass',function(){
gulp.src('./ sass / main.sass')
.pipe(sass({sourceComments:'normal'} ))
.pipe(gulp.dest('./ css'));
});



注意



使用此代码段查看以下引用和问题。


Libsass 2.0 brought the indented syntax to libsass users, but so far I've been unable to make it work with node-sass and gulp-sass. I have all of the latest versions:

node-sass: 0.93
gulp-sass: 0.7.2
gulp: 3.8.2

This setup compiles .scss files and even .sass files using the bracket syntax but it will not compile the indented syntax. Has anyone successfully compiled the indented syntax with node-sass and gulp?

My gulpfile.js

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task('sass', function() {
    return gulp.src('./sites/all/themes/nsfvb/sass/screen.sass')
        .pipe(sass({
            includePaths: require('node-neat').includePaths,
            errLogToConsole: true
        }
        ))
        .pipe(gulp.dest('./sites/all/themes/nsfvb/css'));
});

gulp.task('watch', function() {
    gulp.watch('./sites/all/themes/nsfvb/sass/*.sass', ['sass']);
});

gulp.task('default', ['sass', 'watch']);


Error when running the default task

error: invalid top-level expression

解决方案

Updated answer:

sass({indentedSyntax: true})

Outdated answer

Answer found here: https://github.com/dlmanning/gulp-sass/issues/55#issuecomment-50882250

Code example found here: https://github.com/chrisdl/gulp-libsass-example/blob/master/gulpfile.js

var gulp = require('gulp');
var sass = require('gulp-sass');

// Run with "> gulp sass" in terminal.
gulp.task('sass', function () {
gulp.src('./sass/main.sass')
    .pipe(sass({sourceComments: 'normal'}))
    .pipe(gulp.dest('./css'));
});

Notice

If you run into issues using this snippet take a look at the following quote and issue.

https://github.com/dlmanning/gulp-sass/issues/158

这篇关于缩进Sass语法不适用于node-sass和gulp-sass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:23