Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/f960f1383d88fdd18f3d to your computer and use it in GitHub Desktop.
Save addyosmani/f960f1383d88fdd18f3d to your computer and use it in GitHub Desktop.
Adding /deep/ to your selectors
/*
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