CSS URL processor
A small module designed to convert relative asset URL's in CSS files into absolute URL's for deployment to a combo handled CDN (yui.yahooapis.com).
When you request a CSS file from a server with a ComboHandler on it, relative CSS assets are broken by default.
If your CSS looks like this:
Located in a file with this path:
Loaded from a ComboHandler like this:
Your Image will resolve to:
When it should resolve to:
That's what this module does!
npm install cssproc
As a file (from
var cssproc = require'../../lib'path = require'path'fs = require'fs';var file = pathjoin__dirname 'a1/f1/f2/test.css';fsreadFilefile 'utf8'cssprocparseroot: __dirnamepath: filebase: ''dataconsole.logstr;;;
It could also be used inside of a combo handler
The value of
base could be:
http://foobar.com/path/towhere protocol will be forced to HTTP
https://foobar.com/path/towhere protocol will be forced to SSL
//foobar.com/path/towhich is protocol agnostic where it uses the protocol for the css file that contains the images.
/path/tofor absolute paths where it uses the domain and protocol from the css file that contains the images.
['http://server1.com/path/to', '//server2.com/path/to', etc]an array of hosts to loop through and alternate in the file to support domain sharding.