Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Comments

@nex3
Copy link
Contributor

nex3 commented May 24, 2018

The documentation for the sourceMap option claims that

Setting the sourceMap option requires also setting the outFile option

However, in practice, if you set sourceMap to a string and don't set outFile, you still get a map buffer in the result. For example:

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

var result = sass.renderSync({
  data: 'a {b: c}',
  sourceMap: 'out.css.map'
});
console.log(result.map.toString());

prints

{
        "version": 3,
        "file": "stdin.css",
        "sources": [
                "stdin"
        ],
        "names": [],
        "mappings": "AAAA,AAAA,CAAC,CAAC;EAAC,CAAC,EAAE,CAAC,GAAE"
}
@ericmorand
Copy link

ericmorand commented Apr 15, 2019

The Result object description is also inaccurate:

entry (String) - The path to the scss file, or data if the source was not a file

As seen on @nex3 example, when the source was not a file, the parh to the SCSS file is not data but stdin.

EDIT: Actually, I'm wrong, stats Result object is correctly returning "data" as entry path. Still it is inconsistent with the value returned in the source map "sources" which is "stdin".

saper added a commit to saper/node-sass that referenced this issue Oct 17, 2019
render() and renderSync() should return "map" property in the results
only if source map has been enabled.
@saper saper self-assigned this Oct 17, 2019
@saper
Copy link
Member

saper commented Oct 17, 2019

Thanks for this - there was even a small bug. render() has always provided a map with the undefined value if the map was not requested, unlike renderSync().

Fixed via #2754

@xzyfer xzyfer closed this as completed in 8498f70 Oct 24, 2019
xzyfer added a commit that referenced this issue Oct 24, 2019
Fix #2394: sourceMap option should have consistent behaviour
This was referenced Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.