npm.io
0.0.2 • Published 11 years ago

onepage-rev

Licence
MIT
Version
0.0.2
Deps
2
Vulns
5
Weekly
0

Onepage Rev

Clone files with MD5 hash in filenames before puroduction.

npm i --save-dev onepage-rev
rev = require 'onepage-rev'
rev.config
  htmlScaner: ->
  cssScaner: ->
rev.run
  base: 'src/'
  src: 'index.html'
  dest: 'dist/'
# => returns a promise

Demo

rev = require 'onepage-rev'

rev.config
  htmlScaner: (text) ->
    collection = []
    match = text.match /([-\w\.\/]+)\.(css|js)(?=")/g
    collection.push match... if match?
    collection

  cssScaner: (text) ->
    collection = []
    r = /([-\w\.\/@]+)\.(css|jpg|png|woff|eot|ttf|svg)(?=('|\)))/g
    match = text.match r
    collection.push match... if match?
    collection

  done: ->

rev.run
  base: __dirname
  src: 'index.html'
  dest: './dist/'
  cdn: 'https://dn-demo.oss.aliyuncs.com'
Details

Format of records:

fullpath: ''
replaceText: '' # found by scaner to be replaced
resolvedPath: ''
hashPath: ''
type: '' # extension name
children: [
  # replaceText
]
License

MIT

Keywords