$ gnpm install css-imports
find all @import in css
$ npm install css-imports -g
Css file a.css
@import url("./b.css");
@import url("c.css");
Run code
var imports = require('css-imports');
imports(fs.readFileSync('a.css'));
return
[
{
string: '@import url("./b.css");',
path: './b.css',
index: 0
},
{
string: '@import url("c.css");',
path: 'c.css',
index: 24
}
]
You can add a callback to replace css file
imports(fs.readFileSync('a.css'), function(item) {
return '@import url("' + resolve(item.path) + '");';
});
Copyright (c) 2014 popomore. Licensed under the MIT license.
Copyright 2013 - present © cnpmjs.org | Home |