Code Monkey home page Code Monkey logo

cache-hash's Introduction

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: []
// }

cache-hash's People

Contributors

lete114 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

whmmm

cache-hash's Issues

SyntaxError: Unexpected token s in JSON at position 0

在这里可以复现

https://www.json.cn/runcode/run_javascript/

JSON.parse([['script', 'src'], ['link', 'href'], ['img', 'src']])
编译错误:
Runtime Error (NZEC)
执行错误:
undefined:1
script,src,link,href,img,src
^

SyntaxError: Unexpected token s in JSON at position 0
    at JSON.parse ()
    at Object. (/box/script.js:1:6)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11

https://github.com/volantis-x/community/actions/runs/6739804617/job/18321927123

> cache-hash --target public --output public

undefined:1
script,src,link,href,img,src
^

SyntaxError: Unexpected token s in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (/home/runner/work/community/community/node_modules/cache-hash/bin/cache-hash:41:26)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.