css-url-edit
Collection of helpers for css url manipulations. Strongly inspired and partially based on code from cssrb project.
Getting Started
Install the module with: npm install css-url-edit
var css_url_edit = ;
Documentation
First of all you need to create an URLs collection from your css file.
var URLS = ;
After that you will have following methids in your code:
getURLs
URLS;
mask {regex} is an optional parameter. It will return not all found URLs, but only URLs that match this RegExp.
Returns array of unique URLs in css document.
changeCSSRoot
URLS;
from_path and to_path must be {string} with absolute path to folders.
Changes relative path of every relative url() address in the URLS object to the new base.
changeURLContent
URLS;
from_value {regexp|string} Mask to select urls with.
to_value {string} Rule to apply on found items.
Replace content of every URL matching RegExp with new content.
rebuildCSS
URLS;
Return compiled css.
Examples
var css_url_edit = ; var URLS = ; URLS; var new_css = URLS;
Release History
0.2.0 What's new
- changeURLContent() can now take string as the first argument.
0.1.0 What's new
- Initial release.
License
Copyright (c) 2013 Alexey Ivanov
Licensed under the MIT license.