Created
April 11, 2018 16:07
-
-
Save lahmatiy/d3f8a76a2a761eecf3af010dc6e53a18 to your computer and use it in GitHub Desktop.
Concat AST with CSSTree. Note that CSSTree lost an original formatting on parsing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const csstree = require('css-tree'); | |
const ast1 = csstree.parse('.a { color: red }', { | |
filename: './a.css', | |
positions: true | |
}); | |
const ast2 = csstree.parse('.b { color: red }', { | |
filename: './b.css', | |
positions: true | |
}); | |
const ast = { | |
type: 'StyleSheet', | |
children: new csstree.List() | |
.appendList(ast1.children) | |
.appendList(ast2.children) | |
}; | |
csstree.generate(ast, { sourceMap: true }); | |
// { css: '.a ...', map: SourceMapGenerator } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment