Skip to content

popomore/css-imports

Repository files navigation

css-imports Build Status Coverage Status

find all @import in css


Install

$ npm install css-imports -g

Usage

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) + '");';
});

LISENCE

Copyright (c) 2014 popomore. Licensed under the MIT license.