question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gulp-sass inserts byte order mark EF BB BF in output

See original GitHub issue

I’ve been getting this odd issue where Chrome ignores some of my @font-face declaration.

After checking the output, I’ve noticed an odd character preceding the declaration, which a hex editor revealed to be EFBBBF (byte order mark).

It is only apparent because i’m piping the output with gulp-header.

My build task is like this:

gulp.task('sass-style', function () {
  return gulp
    .src('scss/build.scss')
    .pipe(sass({outputStyle: 'compressed'}).on('error', function(err) {notify().write(err); this.emit('end');}))
    .pipe(rename('style.css'))
    .pipe(header('/*! <%= name %> - <%= version %> - <%= author %>  <%= (new Date()).getFullYear() %> */',pkg ))
    .pipe(gulp.dest('build/'))
    .pipe(browserSync.stream())
  ;
});

The BOM gets placed right after the header, but it isn’t inserted by gulp-header itself, which just concatenates the header with the piped output.

I’ve tried to remove some of the stream handler to make sure they’re not the culprit.

gulp.task('sass-style', function () {
  return gulp
    .src('scss/build.scss')
    .pipe(sass({outputStyle: 'compressed'}).on('error', function(err) {notify().write(err); this.emit('end');}))
    .pipe(gulp.dest('build/'))
    .pipe(browserSync.stream())
  ;
});

And checked the out with Text Wrangler (osx) and it confirms that a BOM is added.

screen shot 2015-09-23 at 14 38 18

Unless i’m missing something in my build script, there seems to be an BOM incorrectly inserted in the output.

(There was a vague mentioned of the BOM in this other issue https://github.com/dlmanning/gulp-sass/issues/82 which said it was marked as fixed in the 2.x branch, but I’m on the latest – 2.0.4 – and it’s happening)

I’ve got the following gulp packages in my build setup:

    "gulp": "^3.9.0",
    "gulp-concat": "^2.6.0",
    "gulp-footer": "^1.0.5",
    "gulp-header": "^1.2.2",
    "gulp-notify": "^2.2.0",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.0.4",
    "gulp-uglify": "^1.2.0",
    "gulp-util": "^3.0.6",
    "gulp-webpack": "^1.5.0",

Happy to test further if you have any suggestions.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
shockthetoastcommented, Mar 23, 2019

Interestingly in compressed mode the @charset isn’t being generated which could be why Chrome is unhappy.

@doginthehat, it turns out that in compressed mode, sass uses the BOM instead of @charset rule because… it’s shorter. https://github.com/sass/sass/issues/1449

The Unicode Guidelines state that using the BOM is allowed in utf-8, but not recommended. (Source: this Stack Overflow answer which links to the official docs.)

The concatenation issue is one reason it’s a terrible idea. I love saving space as much as the next guy, but I don’t feel the savings sixteen characters is worth it. (From the 17 characters of @charset "UTF-8"; to the one BOM character.)

Of course, this being done by sass itself, and not gulp-sass, so it can’t be fixed here. But hopefully this information is helpful to someone.

1reaction
kapooostincommented, Mar 11, 2019

@shockthetoast Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - gulp-sass inserts byte order mark EF BB BF in output -
After checking the output, I've noticed an odd character preceding the declaration, which a hex editor revealed to be EFBBBF (byte order mark)....
Read more >
EF BB BFindustry hot water atmospheric boiler manufacturers
clay originate from the ironmaking BF industry, where the high-productivity. gulp-sass inserts byte order mark EF BB BF in output · Issue #348....
Read more >
Untitled
Fiat allis ad 41, Frases zika de bom dia? ... Free float index calculation, Hemofil package insert, The heat online subtitulada, Comfortis for...
Read more >
ASP.NET 5 Documentation
The easiest way to get started building application with ASP.NET 5 is to install the latest version of Visual Studio 2015.
Read more >
Untitled
Carriage of goods by sea wilson, Caringal scout camp erica, Reifen kennung w, Ccm malaysia stock, Freaky mood instagram videos, Apa nama bb...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found