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.

Should output UTF-8 BOM when input contains UTF-8 BOM

See original GitHub issue

Bug report

When integrate with sass-loader, it will output CSS with UTF-8 BOM (i.e. \uFEFF) at the beginning of the CSS when it is run in production mode. But this plugin seems trimmed the UTF-8 BOM in the final output CSS file. This is a reproducible sample repository (https://github.com/sammyhk/scss-utf8.git). Execute npm run sass which call sass directly produce the CSS file (./dist/in.scss.bom.min.css) with UTF-8 BOM included. Execute npm run build which involve webpack, sass-loader and this plugin produce the CSS file (./dist/in.scss.min.css) without UTF-8 BOM.

Actual Behavior

Seems this plugin trimmed the UTF-8 BOM and output CSS file without BOM.

Expected Behavior

Should preserve the UTF-8 BOM if exists and output CSS file with BOM.

How Do We Reproduce?

This is a reproducible sample repository (https://github.com/sammyhk/scss-utf8.git). Execute npm run sass which call sass directly produce the CSS file (./dist/in.scss.bom.min.css) with UTF-8 BOM included. Execute npm run build which involve webpack, sass-loader and this plugin produce the CSS file (./dist/in.scss.min.css) without UTF-8 BOM.

Please paste the results of npx webpack-cli info here, and mention other relevant information

System: OS: Windows 10 10.0.19042 CPU: (8) x64 Intel® Core™ i7-10510U CPU @ 1.80GHz Memory: 2.59 GB / 15.79 GB Binaries: Node: 12.22.4 - C:\Program Files\nodejs\node.EXE npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 92.0.4515.131 Edge: Spartan (44.19041.1023.0), Chromium (92.0.902.84) Internet Explorer: 11.0.19041.1 Packages: html-webpack-plugin: ^5.3.2 => 5.3.2 webpack: ^5.51.2 => 5.51.2 webpack-cli: ^4.8.0 => 4.8.0 webpack-dev-server: ^4.1.0 => 4.1.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Sep 4, 2021

Honestly we have here to remove BOM in webpack, some developers want to keep them, some to remove 😕

0reactions
alexander-akaitcommented, Sep 7, 2021

dart-sass adds @charset when you have non ascii characters in your file https://github.com/webpack-contrib/sass-loader/pull/985/ (need update to the latest version), so now we should handle it for css-loader and problems will be solved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display problems caused by the UTF-8 BOM - W3C
First, we need to check whether there is indeed a BOM at the beginning of the file. You can try looking for a...
Read more >
What's the difference between UTF-8 and UTF-8 with BOM?
Short answer: In UTF-8, a BOM is encoded as the bytes EF BB BF at the beginning of the file. Long answer: Originally,...
Read more >
FAQ - UTF-8, UTF-16, UTF-32 & BOM - Unicode
If there is no BOM, the encoding could be anything. Where a text data stream is known to be plain Unicode text (but...
Read more >
OUTPUT TO does not include byte-order mark (BOM) when ...
Note that for UTF-8 encoding, the BOM is not byte-order dependent and can be used across platforms. This is because the encoding itself...
Read more >
Byte order mark - Wikipedia
BOM use is optional. Its presence interferes with the use of UTF-8 by software that does not expect non-ASCII bytes at the start...
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