Skip to content

Commit

Permalink
fix source map generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jan 16, 2017
1 parent 2c57b19 commit 7670176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/translateWithSourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function createSourceNode(info, children) {
}

return new SourceNode(
info.start ? info.line : null,
info.start ? info.start.line : null,
info.start ? info.start.column - 1 : null,
info.source,
children
Expand Down
11 changes: 11 additions & 0 deletions test/translateWithSourceMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,15 @@ describe('translateWithSourceMap', function() {
});
}, /Unknown node type/);
});

it.only('should generate a map', function() {
var ast = parse('.a {\n color: red;\n}\n', {
filename: 'test.css',
positions: true
});
var result = translateWithSourceMap(ast);

assert.equal(result.css, '.a{color:red}');
assert.equal(result.map.toString(), '{"version":3,"sources":["test.css"],"names":[],"mappings":"AAAA,E,CACE,S"}');
});
});

0 comments on commit 7670176

Please sign in to comment.