cache-hash
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.11 • Public • Published

Cache-hash

visitor version license

Installation

npm install cache-hash -D

Or global install

npm install cache-hash -g

Use CLI

cache-hash --target source --output public

Or

cache-hash -t source -o public

See help cache-hash --help for more configuration

$ cache-hash --help
Usage: cache-hash [options]

Options:
  -v, --version          output the version number
  -t, --target <target>  Target resource directory (default: "./")
  -o, --output <output>  Output directory, If not set, he will overwrite the "target" content
  --size <size>          Generate hash length (default: 10)
  --key <key>            Version key (default: "v")
  --lazy <lazy>          Select the specified dom element. Example: `'[["a","b"]]'` selects the img tag, and the img tag must contain the lazy attribute (default: [['script', 'src'], ['link', 'href'], ['img', 'src']])
  --html <html>          Generate hash for html referenced resources (default: true)
  --css <css>            Generate hash for css referenced resources (default: true)
  --js <js>              Generate hash for js referenced resources (default: true)
  --style <style>        Generating hashes for resources referenced by style tags (<style>) (default: true)
  --script <script>      Generating hashes for resources referenced by script tags (<script>) (default: true)
  --ignore <ignore...>   Ignore the specified directory or file (default: [])
  -h, --help             display help for command

Use JavaScript API

const cacheHash = require('cache-hash')

cacheHash({
  target: 'source',
  output: 'public'
})

// Please see the cli help parameter description above
// defualtOptions: {
//   target: process.cwd(), // Current command line path
//   output: process.cwd(), // Current command line path
//   size: 10,
//   versionKey: 'v',
//   selectAll: [ [ 'script', 'src' ], [ 'link', 'href' ], [ 'img', 'src' ] ],
//   html: true,
//   css: true,
//   js: true,
//   style: true,
//   script: true,
//   ignore: []
// }

Package Sidebar

Install

npm i cache-hash

Weekly Downloads

5

Version

1.0.0-beta.11

License

MIT

Unpacked Size

27.6 kB

Total Files

34

Last publish

Collaborators

  • lete114