Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

css-reurl

2.0.4 • Public • Published

css-reurl stability

npm version downloads travis build

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 source

  • fn(url)<function> return the newurl, or a promise resolves the newurl

  • done(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)

license

MIT

Keywords

none

Install

npm i css-reurl

DownloadsWeekly Downloads

2

Version

2.0.4

License

MIT

Last publish

Collaborators

  • avatar