map.sourcesContent doesn't work together with map.from
See original GitHub issueconst postcss = require('postcss');
const autoprefixer = require('autoprefixer');
const options = {
from: 'src/test.css',
to: 'src/test.css!postcss',
map: {
inline: false,
annotation: false,
sourcesContent: true,
from: 'src/test.css'
}
};
const instance = postcss([ autoprefixer({ browsers: '>0%' }) ]);
const result = instance.process('.test { border-radius: 5px }', options);
console.log(result.map.toJSON());
code below will produce sourcesContent: [ null ]
instead of sourcesContent: [ '...' ]
but will produce correct source name src/test.css
.
If i will remove from
option then sourcesContent
will have correct value but sources
will have test.css
instead of src/test.css
.
So there is no way to keep correct source name together with source content.
Looks like a two defects:
options.from
with full path truncated to basename by default and source map looses original source file path- workaround with
options.map.from
keeps correct source file path but doesn’t work well withoptions.map. sourcesContent = true
(breaks source content)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
4 Reasons Why Your Source Maps are Broken - Sentry Blog
Source maps are awesome... when they work. ... This likely means that your source map doesn't contain or link to your original source...
Read more >Do source maps include the source text? - Stack Overflow
Source maps can optionally include the original source. From the spec, sourcesContent is "An optional list of source content, ...
Read more >Source-maps could be revealing your private project files
The CLI will generate bundle files automatically along with files called “source-maps”. Every time you make production build of your app, “.js.
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 >Anatomy of source maps | Bugsnag Blog
Learn how source maps work by examining their inner workings through ... JS, however, doesn't provide a way (yet) to import code from...
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 Free
Top 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
Hi, I think I hit the same issue when running
postcss
onnode-sass
output. ifmap.from
is set, the resulting.map
file only references the empty virtual file, while all original sass maps are gone.I found problem. It was because of wrong content of
opts.map.from
. It should be relative fromto
(in this case it should betest.css
).I fixed docs: https://github.com/postcss/postcss/commit/30ac96f1a93484a591ba94a98e6a8aba519b3d37
opts.map.from
is low-level option for rare edge cases. You should not use it.