npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rev-static

v3.6.0

Published

Static asset revisioning by appending content hash to filenames, then changing the names in html files.

Downloads

187

Readme

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

key | description --- | --- -w,--watch | watch mode --config | config file -h,--help | Print this message. -v,--version | Print the version

config file

key | type | use case | description --- | --- | --- | --- inputFiles | string[] | demo/index.js | the js, css, html and image file paths, can be glob excludeFiles | string[]? | node_modules/foo/bar.js | the files will be excluded, can be glob revisedFiles | string[]? | demo/foo-caa02eaf68e9a.js | the files will be regarded as revised files, can be glob inlinedFiles | string[]? | demo/index.css | the files will be inlined to html files, can be glob outputFiles | (file: string) => string | demo/index.ejs.html->demo/index.html | the output files mapping function ejsOptions | EjsOption | rm whitespace | the options to ejs sha | 256 or 384 or 512 or undefined | subresource integrity | the sha type for subresource integrity customNewFileName | (filePath: string, fileString: string, md5String: string, baseName: string, extensionName: string) => string | demo/index.js->demo/index-caa02eaf68e9a.js | the rule of generated js, css, image file customOldFileName | (filePath: string, baseName: string, extensionName: string) => string | demo/index-caa02eaf68e9a.js->{ demoIndexJs: demo/index-caa02eaf68e9a.js } | the rule to get revised file's key json | string? | | generate json file for other use es6 | string? | | generate es6 file for image resources less | string? | | generate es6 file for image resources scss | string? | | generate es6 file for image resources base | string? | | for example, if no base, the key will be demoFooJs or demoBarCss, if the base is demo, the key will be fooJs or barCss fileSize | string? | | generate a json file to show the resource file size context | any? | | 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 });