Last active
August 29, 2015 14:02
-
-
Save addyosmani/f960f1383d88fdd18f3d to your computer and use it in GitHub Desktop.
Adding /deep/ to your selectors
This file contains 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
/* | |
This POC sample uses CSS transform which you can install from | |
https://www.npmjs.org/package/csstransform | |
Save this to deep.js and just run via node | |
*/ | |
var css = __dirname + '/vendor/bootstrap.css'; | |
var target = __dirname + '/dist/bootstrap-deep.css'; | |
var csstransform = require('csstransform'); | |
var csst = csstransform(css); | |
csst.transformSelectorText({ | |
prepend: '/deep/', | |
// Match all CSS selectors. Use "([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)" or the below. | |
match: "/^(-?<=#|\.|\#)(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)(?=[^}]+{)*$/g" | |
}); | |
csst.toString(target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment