Source map line numbers off by two with no plugins #926

alexturpin opened this Issue Dec 2, 2016 · 5 comments


None yet

2 participants


Hey all,

I've encountered a bit of an issue with sourcemaps. My workflow is that I first compile my SASS code down to CSS, and then use PostCSS on the resulting code / source maps.

My problem is that even with no plugins, after going through PostCSS, source map line numbers are off by 2 (they point to 2 lines before the actual line).

This is the input CSS and input source map generated from SASS:


/*# */
	"version": 3,
	"file": "styles.css",
	"sources": [
	"sourcesContent": [
		"p {\n\tcolor: red;\n}\n\na {\n\tcolor: green;\n}\n"
	"names": []

As can be seen on source-map-visualization everything is still linked properly.

Now running them through PostCSS without plugins with this code:

var postcss = require('postcss');
var fs = require('fs');
var path = require('path');

var beforeStyles = fs.readFileSync('before.css', 'utf-8');
var beforeMap = fs.readFileSync('', 'utf-8');

	.process(beforeStyles, { from: 'before.css', to: 'after.css', map: { inline: false, prev: beforeMap } })
	.then(function(result) {
		fs.writeFileSync('after.css', result.css);
	}, function(err) {

Results in the following output:

/*# */
{"version":3,"sources":["styles.scss"],"names":[],"mappings":"AAAA,EACC,SAAW,CACX,EAGA,WAAa,CACb","file":"after.css","sourcesContent":["p {\n\tcolor: red;\n}\n\na {\n\tcolor: green;\n}\n"]}

Which, we can observe on source-map-visualization, is broken. The a selector has no corresponding line number.

ai commented Dec 2, 2016 edited

Thanks for investigation. Yeap, a selector mapping is broken.

Right now I am preparing for conference and will be free after Dec 11. Could it wait until this date? Maybe I will have time on next week.


@ai Yep that's fine, just wanted to make sure that it was logged somewhere.



Just wondering if there have been any updates on this? :)

ai commented Jan 4, 2017

Sorry, I am in other project. Because we had no other reports and problem is not critical this issue is low priority right now.

Do you want to try to fix it by your own? I will help you.


No worries. It's not critical enough for me right now to focus time on fixing it, but if I ever come around to it I'll hit you up to ask for tips on where to look to fix it :)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment