sass/node-sass

BOM triggers invalid CSS exception

Closed this issue · 6 comments

Using gulp-sass in the following way is causing an error with single line comments in imports:

gulp.task('build:sass', function () {
    return gulp.src('./wwwroot/theme/**/*.sass', { base: './' })
        .pipe(sass({
            precision: 6,
            sourceMap: true,
            includePaths: [
                './wwwroot/css',
                './wwwroot/lib'
            ]
        }).on('error', sass.logError))
        .pipe(gulp.dest('./'));
});

test.sass

@import config

// =================================================== //
// EDIT THIS FILE                                      //
// =================================================== //

$background: red

body
    background: $background

_config.sass

// =================================================== //
// DO NOT EDIT THIS FILE                               //
// =================================================== //

$background: black

Log

[16:23:02] Using gulpfile C:\Projects\ReadySet\Gulpfile.js
[16:23:02] Starting 'build:sass'...
Error in plugin 'sass'
Message:
    wwwroot\theme\_themeTemplate\css\_config.sass
Error: Invalid CSS after "": expected 1 selector or at-rule, was "{}// =============="
        on line 1 of wwwroot/theme/_themeTemplate/css/_config.sass
[16:23:02] Finished 'build:sass' after 42 ms
>>  {}// =================================================== //
   ^
Process terminated with code 0.

I am unable to reproduce this with the latest node-sass. Please make sure you're running at least node-sass@3.8.0. You can use the following command to make sure you're up to date.

npm outdated

@xzyfer Awe... I see the issue is the BOM. Shouldn't node-sass account for the possible BOM?

I'm using the latest version.

Shouldn't node-sass account for the possible BOM

Yes. Can you confirm if this issue is present when using the SCSS syntax?

No. The issue isn't present in the SCSS syntax.

Thanks @roydukkey this suggest the issue is in the sass2scss library used inside of LibSass /cc @mgreter