Skip to content

teabyii/css-resources

 
 

Repository files navigation

css-resources

NPM version Build Status Coverage Status NPM downloads

Find and replace all image and font resources in css.


Install

$ npm install css-resources -g

Usage

CSS file a.css

body {
  background: url(./a.png);
}
@font-face {
  src: url('./font.eot');
}

Parse CSS with resource

var resources = require('css-resources');
resources(fs.readFileSync('a.css'));

Return

[
  {
    property: 'background',
    string: 'url(./a.png)',
    path: './a.png'
  },
  {
    property: 'src',
    string: 'url(\'./font.eot\')',
    path: './font.eot'
  }
]

You can add a callback to replace css file

resources(fs.readFileSync('a.css'), function(item) {
  return 'url("' + resolve(item.path) + '");';
});

LISENCE

Copyright (c) 2015 chencheng. Licensed under the MIT license.

About

Find and replace all *image* and *font* resources in css.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 69.6%
  • CSS 22.2%
  • Makefile 8.2%