0.3 “Prince Seere”
This release improve source map support, copy your code style in new nodes and add few API.
Source Map
If you generate map for your changes, output CSS will contains source map annotation comment:
a { }
/*# sourceMappingURL=to.css.map */
Now you can inline source map to annotation comment by data:uri
. Use inlineMap
option:
var result = porcessor.process(css, { inlineMap: true });
result.map //=> undefined, because map is in CSS
result.css //=> "a{}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5taW4uY3NzIiwic291cmNlcyI6WyJtYWluLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFLIn0= */"
PostCSS will autodetect previous source map if map is in annotation comment or in file near input CSS. You can disable autodetection by map: false
option.
Source map now has special fixes to works on Windows and in subdirectories. Thanks to @nDmitry and @lydell, they did great investigation.
Code Style
New rule will copy style from parsed rules:
var root = postcss,parse(".empty {};\na {\n color: black;\n }");
var rule = postcss.rule({ selector: 'b' });
root.append(rule);
rule.toString(); //=> "b {}"
// copy style from empty rule
rule.append({ prop: 'top', value: '1px' });
rule.toString(); //=> "b {\n top: 1px;\n }"
// copy style from rule with declaration
Selector and at-rule params was cleaned from spaces and comments before {
. AtRule
and Rule
nodes now has between
property. Declaration
also has between
property with colon, spaces and comments between property name and value.
API Changes
- Comments between rules and declarations now parsed to
Comment
node. - Container node now has
first
andlast
shortcut with first or last child. - Declaration value will not contains
!important
rule anymore. It will be parsed to separatedimportant
property. - You can now break any nodes iteration with return
false
. - New method
eachInside()
allow you to recursive iterate node of all types. - Rule now contains
selectors
shorcut property, which returns selectors in array. - In 0.3 process multiple input files will be easy by
toResult()
method inRoot
.