Indented Sass syntax not working with node-sass and gulp-sass

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')
            includePaths: require('node-neat').includePaths,
            errLogToConsole: true

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

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

Error when running the default task

error: invalid top-level expression

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Updated answer:

If you want to use the indented syntax (.sass) as the top level file, use sass({indentedSyntax: true}).

sass({indentedSyntax: true})

Outdated answer

Answer found here:

With default settings compiling sass files doesn’t work. However there is a workaround. If you pass sourceComments: ‘normal’ as parameter the compilation work. The reason for this is that there is a strange condition which change how file are handled:

Code example found here:

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

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


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

Using this workaround will result in any changes to the file content from earlier in the gulp pipeline (e.g. earlier plugins) being discarded – JMM

Solution 2

Just to update this answer, the documentation for gulp-sass now says:

If you want to use the indented syntax (.sass) as the top level file, use sass({indentedSyntax: true}).

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply