0.4.0 • Published 9 years ago

wesber v0.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

wesber

npm version Build Status Coverage Status

A simple web resource dependencies finder and replacer.

Why make this? When we try to build web static files, we should trace all of the resources which the page depends. Then need a tool to help find the dependencies and replace their url (using hash as placeholder), which is wesber.

Usage

API

const { css, html } = require('wesber')

css('style.css').then((result) => {
  ...
  // result = { file: ..., source: ..., replacer: ..., dependencies: [ ...] }
})

html('index.html', {
  resolved: [ 'script' ]
}).then((result) => {
  ... // result structure is the same, but just script tag.
})

Example

result:

result = {
    file: '/Users/boom/Github/wesber/test/files/style.css',
    source: '.icon-a{\nbackground: url(foo.png)no-repeat;\n}\n',
    replacer: '.icon-a{\nbackground: url(#b0b5895c)no-repeat;\n}',
    dependencies: [
        {
            file: 'foo.png',
            hash: '#b0b5895c',
            entireUri: false,
            base64: false,
            path: '/Users/boom/Github/wesber/test/files/foo.png',
            exists: false
        }
    ]
}

License

MIT

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago