css-reurl
v2.0.4
Published
rewrite css url asynchronous
Downloads
2
Readme
css-reurl
Rewrite all css url property asynchronously.
works with async functions (node 7.6+)
usage
const fs = require('fs')
const base64Img = require('base64-img')
const cssReurl = require('css-reurl')
fs.readFile('test.css', (err, input_css) => {
cssReurl(input_css, url => {
return new Promise((resolve, reject) => {
base64Img.base64(url, (err, newurl) => {
if (data === void 0){
resolve(url)
}
resolve(newurl)
})
})
}, output_css => {
console.log(output_css)
})
})
api
cssReurl(src, fn, done)
src<string|buffer>
css sourcefn(url)<function>
return the newurl, or a promise resolves the newurldone(newcss)<function>
rewrote callback with the new source
cssReurl(src, url => {
return url + "abc"
}, done)
// asynchronously
cssReurl(src, url => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(url + "abc")
}, 1000)
})
}, done)