broccoli-asset-rev

broccoli asset revisions (fingerprint)

MIT 50 个版本
安装
npm install broccoli-asset-rev
yarn add broccoli-asset-rev
pnpm add broccoli-asset-rev
bun add broccoli-asset-rev
README

broccoli-asset-rev

Build Status codecov.io npm

Broccoli plugin to add fingerprint checksums to your files and update the source to reflect the new filenames.

Turns

<script src="assets/appname.js">
background: url('/images/foo.png');

Into

<script src="https://subdomain.cloudfront.net/assets/appname-342b0f87ea609e6d349c7925d86bd597.js">
background: url('https://subdomain.cloudfront.net/images/foo-735d6c098496507e26bb40ecc8c1394d.png');

Installation

npm install broccoli-asset-rev --save-dev

Usage

var AssetRev = require('broccoli-asset-rev');

var assetNode = new AssetRev(node, {
  extensions: ['js', 'css', 'png', 'jpg', 'gif'],
  exclude: ['fonts/169929'],
  replaceExtensions: ['html', 'js', 'css'],
  prepend: 'https://subdomain.cloudfront.net/'
});

Options

  • extensions - Default: ['js', 'css', 'png', 'jpg', 'gif', 'map'] - The file types to add md5 checksums.
  • exclude - Default: [] - An array of globs. If a filename contains any item in the exclude array, it will not be fingerprinted.
  • replaceExtensions - Default: ['html', 'css', 'js'] - The file types to replace source code with new checksum file names.
  • prepend - Default: '' - A string to prepend to all of the assets. Useful for CDN urls like https://subdomain.cloudfront.net/
  • generateRailsManifest - Default: none - If true, will generate a manifest.json to be used by Sprockets for the Rails Asset Pipeline. The manifest will be fingerprinted by default but this can be avoided by adding 'manifest.json' to the exclude list.
  • railsManifestPath - Default: 'assets/manifest-HASH.json' - The path in the destination folder to store the Rails manifest. Only for the default value, HASH will be replace with the fingerprint of the file.
  • customHash - Default: none - If set, overrides the md5 checksum calculation with the result of calling customHash(buffer, pathToFile). If it is not a function, customHash is used as the hash value. If it is set to null, fingerprinting is skipped and only prepending occurs.
  • generateAssetMap - Default: false. If true, will generate a assetMap.json file in a assets directory on the output node. This file contains a mapping of the original asset name to the fingerprinted asset, like the following:
  • assetMapPath - Default: 'assets/assetMap-HASH.json' - The path in the destination folder to store the assetMap.json in. Only for the default value, HASH will be replace with the fingerprint of the file.
{
	assets: {
		css/file1.css: css/file1-sdaa7d6a87d6ada78ds.css,
		images/image1.png: images/image1-sdaa7d6a87d6ada78ds.css,
	}
}
  • fingerprintAssetMap - Default: false. If true, will fingerprint assetMap.json.
  • ignore - Default: [] - An array of strings. If a filename contains any item in the ignore array, the contents of the file will not be processed for fingerprinting.
  • annotation - Default: null. A human-readable description for this plugin instance.

Default settings

The default settings are available if needed in your application or addon via: var broccoliAssetRevDefaults = require( 'broccoli-asset-rev/lib/default-options' );

Ember CLI addon usage

var app = new EmberApp({
  fingerprint: {
    exclude: ['fonts/169929'],
    prepend: 'https://sudomain.cloudfront.net/'
  }
});

Ember CLI addon options

  • enabled - Default: app.env === 'production' - Boolean. Enables fingerprinting if true. True by default if current environment is production.
  • exclude - Default: [] - An array of globs. If a filename contains any item in the exclude array, it will not be fingerprinted.
  • extensions - Default: ['js', 'css', 'png', 'jpg', 'gif', 'map'] - The file types to add md5 checksums.
  • prepend - Default: '' - A string to prepend to all of the assets. Useful for CDN urls like https://subdomain.cloudfront.net/
  • replaceExtensions - Default: ['html', 'css', 'js'] - The file types to replace source code with new checksum file names.

ghit.me

版本列表
3.0.0 2018-08-13
2.7.0 2018-03-29
2.6.0 2017-08-14
2.5.0 2016-10-14
2.4.6 2016-08-09
2.4.5 2016-07-26
2.4.4 2016-06-30
2.4.3 2016-06-18
2.4.2 2016-01-23
2.4.1 2015-12-11
2.4.0 2015-12-10
2.3.0 2015-10-10
2.2.0 2015-09-02
2.1.3 2015-08-26
2.1.2 2015-08-08
2.1.1 2015-08-02
2.1.0 2015-06-25
2.0.6 2015-06-20
2.0.5 2015-05-29
2.0.4 2015-05-29
2.0.3 2015-03-23
2.0.2 2015-03-16
2.0.1 2014-12-29
2.0.0 2014-12-13
1.1.1 2014-12-06
1.1.0 2014-12-04
1.0.1 2014-11-20
1.0.0 2014-11-19
0.3.1 2014-10-01
0.3.0 2014-10-01
0.2.0 2014-09-26
0.1.1 2014-09-09
0.1.0 2014-09-05
0.0.17 2014-07-22
0.0.16 2014-07-11
0.0.15 2014-07-04
0.0.14 2014-07-03
0.0.13 2014-07-02
0.0.12 2014-07-02
0.0.11 2014-07-02
0.0.10 2014-07-01
0.0.9 2014-06-25
0.0.8 2014-06-19
0.0.7 2014-06-18
0.0.6 2014-06-13
0.0.5 2014-05-28
0.0.4 2014-05-26
0.0.3 2014-05-25
0.0.2 2014-05-25
0.0.1 2014-05-25