$ npm install css2str
Transform css to string that can be inserted by js
$ npm install css2str -g
var css2str = require('css2str');
var code = css2str(fs.readFileSync(filepath));
Then you can use import-style to import css in browser.
var importStyle = require('import-style');
importStyle(code);
This option will add a parent selector of every selector.
// origin css
a {
border: none;
}
// yield
.container a{border: none;}
With code
var opt = {prefix: '.container'}
var code = css2str(fs.readFileSync(filepath), opt);
Copyright (c) 2014 popomore. Licensed under the MIT license.
© 2010 - cnpmjs.org x YWFE | Home | YWFE