Dealing with previous sourcemaps
See original GitHub issueJust a quick question about a problem I encountered. Here is a structure:
_ assets
|_ dist
|_ main.css
|_ main.css.map
|_ sources
|_ scss
|_ main.scss
|_ _partials.scss
When node-sass parses main.scss
, it creates main.css
and main.css.map
. In sourcemaps file, sources
are relative, like for example: ../sources/scss/main.scss
, but there is not sourceRoot
.
When postcss tries to use previous sourcemaps, it rewrites ../sources/scss/main.scss
to ../sources/sources/scss/main.scss
and it fails.
In map.generator.js:115
, this.map.applySourceMap(map, from, this.relative(root))
:
from
is equal to../sources/scss/main.scss
this.relative(root)
is equal to../sources/scss
while it should be equal to../scss
to make it work.
Any idea where the problem is?
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Source maps and how it works - Ehsan Gazar
Source maps can be convenient during development. They provide better means to debug applications as you can still examine the original code ...
Read more >Use a source map — Firefox Source Docs documentation
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original...
Read more >4 Reasons Why Your Source Maps are Broken - Sentry Blog
4 Reasons Why Your Source Maps are Broken · Missing or incorrect source map directive · Missing original source files · Bad source...
Read more >JavaScript Debugging with Sourcemaps - TrackJS
The main purpose of sourcemaps is to aid debugging. Basically, if there's an error in the generated code file, the map can tell...
Read more >Should I Use Source Maps in Production? | CSS-Tricks
A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to the original authored version....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I found a solution using the
prev
key. When I first usedprev
I would get an error telling me that that it was an unsupported format.css.map
is a properly formatted sourcemap from node-sass. The Postcss documentation says thatprev
accepts an object.If I convert the map to a string then
prev
works just fine.I’m having the same issue. I have a single scss file that imports other scss files. The sourcemap from node-sass properly lists all the scss files in the sources array of the sourcemap. Once the css is run through Postcss the sources array now only points to the single scss file that imports everything.
This is my main scss file.
Here are my scripts for node-sass and postcss
Here is what Postcss outputs for the sourcemap
How do I get Postcss to still reference all the correct scss files that are imported by the main scss file?