3.6.0 • Published 4 years ago

rev-static v3.6.0

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

rev-static

Dependency Status devDependency Status Build Status: Linux Build Status: Windows npm version Downloads type-coverage

features

add version in file name for css and js files

index.js

becomes:

index-caa02e8ba0c5af68e9ac7728da2bed75.js

change file name of css and js files in html files

<script src="index.js"></script>

becomes:

<script src="index-caa02e8ba0c5af68e9ac7728da2bed75.js"></script>

calculate sha for css and js files, then add it in integrity property

<script src="index.js" crossOrigin="anonymous"></script>

becomes:

<script src="index-caa02e8ba0c5af68e9ac7728da2bed75.js" crossOrigin="anonymous" integrity="sha256-cHLd68M3ekn8P2d8tYdJIV91nSbWrWsu02yI8MEVvYU="></script>

support glob

support config file for options

rev-static --config rev-static.debug.js

inline small js or css file

install

yarn global add rev-static

usage

rev-static --config rev-static.config.js // config the config file path
rev-static -v
rev-static --version
rev-static --watch
rev-static --config rev-static.config.ts

options

keydescription
-w,--watchwatch mode
--configconfig file
-h,--helpPrint this message.
-v,--versionPrint the version

config file

keytypeuse casedescription
inputFilesstring[]demo/index.jsthe js, css, html and image file paths, can be glob
excludeFilesstring[]?node_modules/foo/bar.jsthe files will be excluded, can be glob
revisedFilesstring[]?demo/foo-caa02eaf68e9a.jsthe files will be regarded as revised files, can be glob
inlinedFilesstring[]?demo/index.cssthe files will be inlined to html files, can be glob
outputFiles(file: string) => stringdemo/index.ejs.html->demo/index.htmlthe output files mapping function
ejsOptionsEjsOptionrm whitespacethe options to ejs
sha256 or 384 or 512 or undefinedsubresource integritythe sha type for subresource integrity
customNewFileName(filePath: string, fileString: string, md5String: string, baseName: string, extensionName: string) => stringdemo/index.js->demo/index-caa02eaf68e9a.jsthe rule of generated js, css, image file
customOldFileName(filePath: string, baseName: string, extensionName: string) => stringdemo/index-caa02eaf68e9a.js->{ demoIndexJs: demo/index-caa02eaf68e9a.js }the rule to get revised file's key
jsonstring?generate json file for other use
es6string?generate es6 file for image resources
lessstring?generate es6 file for image resources
scssstring?generate es6 file for image resources
basestring?for example, if no base, the key will be demoFooJs or demoBarCss, if the base is demo, the key will be fooJs or barCss
fileSizestring?generate a json file to show the resource file size
contextany?will be available when render html template, eg, context: { foo: 1 }, then context.foo === 1

core structure

{
  "sri": {
    "fooJs": "sha256-+dZ6udsWxNVoGfScAq7t5IIF5UJb4F6RhjbN6oe1p4w=",
    "foo2Js": "sha256-472ZphjBz2mNWVsknzB8w8rybok1qJl+LKGkqi4XX54=",
    "barCss": "sha256-up7mALOXxS9RzUpTmUIG02GpdK3MsSiMX1Zvco/4J68=",
    "testPng": "sha256-s6pVclbzXpnC5m5oiDf3vdHQskc3AX1vz6h3HRYHgkQ="
  },
  "fooJs": "foo-cb6143ff70a133027139bbf27746a3c4.js",
  "foo2Js": "foo2-42a7b8c.js",
  "barCss": "bar-84f794affa62674553872916601669fe.css",
  "testPng": "test-9d97966727a2d68e865bd7dcf26202df.png"
}

demo in this repository

  1. download or clone this repository
  2. run rev-static(the options is already in rev-static.config.js)

develop

check scripts part in package.json file, then run npm run [a script name].

change logs

v3

  • noOutputFiles removed
  • Usage from nodejs removed
  • All cli command except -v, --version, --config removed, in favor of config file
  • the outputFiles cannot be string[] any more

v2

// before
// default configuration file path: rev-static.config.json

// after
// default configuration file path: rev-static.config.js
// before
rev.revisionCssJs(["demo/foo.js", "demo/bar.css"], { shaType: 256 }).then(variables => { });

// after
const variables = rev.revisionCssJs(["demo/foo.js", "demo/bar.css"], { shaType: 256 });
3.6.0

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.5

4 years ago

3.4.4

4 years ago

3.4.3

5 years ago

3.4.2

6 years ago

3.4.1

7 years ago

3.4.0

7 years ago

3.3.1

7 years ago

3.3.0

7 years ago

3.2.2

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.7.1

7 years ago

2.7.0

7 years ago

2.6.0

7 years ago

2.5.0

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.1

7 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago