javascript - Remove properties from rendered Less CSS -
Some patterns appear in the Kamass (1.7.x) that allow the processing of a CSS render (pre / post) Gives tree I was wondering if it was possible to use the visitor (I tried, but it could not work - or something else) to remove the presentation from the CDS output. As if the output happens
a {font-size: 12px; - Some-uncover-property: value; }
I would like to remove -some-arbitrary-property
from CSS output when calling .toCSS
I can not find any documentation about this, only the context of the upcoming version 2.0 - does anyone know that this is possible and if yes, how to do it, or point me to some example?
From less v2, you can use. You can also use a visitor in your plugin. An example of using a visitor can be found here.
Within your Visitor Plugin you can use some of the following types shown:
visitRule: function (ruleNode, visitArgs) {If (ruleNode.name [0 ] .value! = '-some-aribitrary-property') {return ruleNode; } And {return []; }}
Note that the above is not currently deleted, but :;
. I will update my reply later, also see:.
This does not work for visitors in v1.7 - do you have an example for this?
For less & lt; V2
Update
has been suggested as to use it yourself:
< Code> var parser = new less.Parser) (); Parser.pars (your lasdaata, function (mistake, tree) {CSS from CSS ({plugins: [remove new ())}}}; With
:
RemoveProperty = function () {this._visitor = new tree.visitor (this); }; RemoveProperty.prototype = {HARITIME: True, PLAY: Function (Route) {return._visitor.visit (Route); }, VisitRule: function (ruleNode, visitArgs) {if (ruleNode.name! = '-some-aribitrary-property') {return ruleNode; } And {return []; }}}; End update create a file in lib / less >> custom-visitor.js < / Code> contains the following content:
(function) {tree.RemoveProperty = function () {this._visitor = new tree.visitor (this);} Tree RemoveProperty.prototype = {Again: true, play: function (root) {return._visitor.visit (root);}, visitRule: function (ruleNode, visitArgs) {if (ruleNode.name! = '-some-aribitrary-property') {Return ruleNode;} and {return [];}}};}) (required ('. / Tree')); Adding less / lib / index.js than
requires ('./custom-visitor.js');
, the end of this file will now appear as shown below:
is required ('. / Env'); Required ('./works'); Required ('./color'); Required ('./ visitor.js'); Required ('./ import visitor.js'); Required ('./extension- visitor.js'); Required ('/ joining-selector-visitor.js'); Requires ('./custom visitor.js'); Required ('./ to-css-visitor.js'); Required ('./ source-map-output.js'); For (var k) in less {if (less.hasOwnProperty (k)) {export [k] = less [k]; }}
and finally new (tree. RAVProperty) (),
in low / lib / parser.js, around the line 554, so that the code looks like this Which is shown as below:
Visitor = [New (tree. Preservationist visitor) (), new (tree.providesexens visitors), new (tree. Rev.Property) (), new (Tree.To CSS visitor) ({Compress: boolean (options.compress)}),
Comments
Post a Comment