npm install generate-hash-files
or
yarn add generate-hash-files
Create file generate-hash-files.json
(if not exist)
Sample:
{
"files": [
{
"id": "Your name",
"input": "./build/",
"output": "./dist/",
"indexFile": "index.json"
}
]
}
Set of release.
Id of config.
Path of folder that contains files to hash
Path of output folder that contains copied files. If omitted, no file is copied.
Index json file path. If ommited, index file is index.json
List of supported file extensions.
Sample:
{
"extensions": [ ".html", ".js", ".css" ]
}
if extensions
was omitted, the default extension list will be used: ".html", ".htm", ".css", ".js", ".json", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".webp", ".ttf", ".woff", ".woff2", ".eot", ".mp3", ".mp4", ".avi"
List of exclusion patterns
Sample:
{
"exclude": [ "data.log", "result_\\d+\\.txt" ]
}
Set of injection rules. inject
will be ignored if output
is omitted or same to input
Sample
{
"inject": {
"Replacement token here. Sample: #GIT_GIT_HASH#": {
"files": [ "./index.html" ],
"value": "Your value. You need to encode yourself",
"env": "Environment name. Ex: NODE_ENV",
"command": "Shell here. Ex: git rev-parse --verify HEAD"
}
}
}
Priority order: value
then env
then command
. Lower priority field will be ignored if higher priority exists.
List of files that will be replaced by value.
Value to replace
Environment name that its value will be used to replace (if files.inject.value
ommited)
Shell command will be exectuted and its output will be used to replace (if files.inject.value
and files.inject.env
ommited)
Transform function. One of: stringify
, trim
, encodeHTML
, encodeURIComponent
.
Config console output. If silent
is true, no message will be outputed.
Sample:
{
"files": [...],
"silent": true
}
npx generate-hash-files