sass / dart-sass

The reference implementation of Sass, written in Dart.
https://sass-lang.com/dart-sass
MIT License
3.92k stars 355 forks source link

Source mappings wrong when using compressed style #1896

Open david10sing opened 1 year ago

david10sing commented 1 year ago

Context

I am experiencing an issue when using the JS API, sourcemap compile option when used in tandem with style = compressed.

The source map is produced and I write it to a file. However, the mappings are broken and in Chrome's devtools, I am seeing styles pointing to the wrong file.

Screenshots

Wrong

image

Correct

image

Question

nex3 commented 1 year ago

Can you provide a minimal repo that reproduces this issue?

david10sing commented 1 year ago

Hi @nex3

Here is a link to a reproduction repo

https://github.com/david10sing/minified-sass-breaking-sourcemap

nex3 commented 1 year ago

That repro looks like it passes the Sass output, including the sourcemap, through PostCSS. Can you reproduce it with Sass alone?

david10sing commented 1 year ago

Hi @nex3

Removed the postcss processing.

As you will see, it has the same issue. I also renamed the class names so it's clearer. .index should come from index.scss but is instead pointing to _test.scss

nex3 commented 1 year ago

I can't reproduce that. Here's what I did:

$ git clone https://github.com/david10sing/minified-sass-breaking-sourcemap
$ cd minified-sass-breaking-sourcemap
$ npm i
$ mkdir dist
$ node sass-compiler.js

I then opened https://sokra.github.io/source-map-visualization/ and uploaded the generated index.css and index.css.map files. The .index class is clearly mapped to the correct location in index.scss.

david10sing commented 1 year ago

@nex3

It's not in chrome devtools inspector

nex3 commented 1 year ago

That sounds like a bug in the chrome devtools inspector. Have you tried reporting it there?

david10sing commented 1 year ago

Thank you @nex3

Reported ☝️

ntkme commented 1 year ago

@david10sing That is not the right place for chrome bugs, please follow instructions on this page: https://www.chromium.org/for-testers/bug-reporting-guidelines/