Use the file option insetad of data for renderSync #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
As I mentioned on #45, when you use
sourceMapEmbed
, you can't the path to the original sources because the node-sassrenderSync
call was made using thedata
option, which is a string with the whole SASS, so the map source is set tostdin
.In order to get the real sources on a source map, you need to use the
file
option, instead ofdata
, with the path of the file that will be processed.Now, the reason
renderSync
is called withdata
is because the plugin allows you to send adata
option with custom SASS code that will be prepended to the contents of the file.Finally, the change I'm proposing is that, when you use the
data
option, the plugin will behave as always and callrenderSync
with the whole code; but if you don't usedata
, the plugin will callrenderSync
with thefile
option.If you noticed that I changed a test asset file, I did it because its extension was
.sass
but the code wasSCSS
, and when you usefile
, you need to use the syntax that matches the extension of the file.How should it be tested manually?
Use the plugin with the
options.sourceMapEmbed
option set totrue
, and don't include adata
option.The generated file will include a huge comment with the source map encoded on Base64; you can use base64decode.org to decode that it, and once you do it, you'll see that
sources
now points to the real files that were encoded.And don't forget to
npm test
.