From 3496e71dfe5c2a0a88dcbd96017eb8877af21563 Mon Sep 17 00:00:00 2001 From: MiguelMadero Date: Thu, 21 May 2020 20:21:05 -0700 Subject: [PATCH] Adds the option to specify files that need a third pass of UseRev --- lib/asset-rev.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/asset-rev.js b/lib/asset-rev.js index 24135e2..7582caf 100644 --- a/lib/asset-rev.js +++ b/lib/asset-rev.js @@ -33,12 +33,24 @@ function AssetRev(inputTree, options) { var assetRewrite = UseRev(fingerprintTree, this); // second pass - fingerprints replaceable source code - this.exclude = exclude; + this.exclude = exclude.slice(); + if (options.filesForThirdPass) { + this.exclude = this.exclude.concat(options.filesForThirdPass); + } this.onlyHash = this.replaceExtensions; var fingerprintTree2 = Fingerprint(assetRewrite, this); var assetRewrite2 = UseRev(fingerprintTree2, this); - return new FastbootManifestRewrite(assetRewrite2, this.assetMap); + // Some files may need to be hashed until the third + // pass since they contain references to other files that are fingerprinted + if (options.filesForThirdPass) { + this.exclude = exclude; + this.onlyHash = options.filesForThirdPass; + var fingerprintTree3 = Fingerprint(assetRewrite2, this); + var assetRewrite3 = UseRev(fingerprintTree3, this); + } + + return new FastbootManifestRewrite(assetRewrite3 || assetRewrite2, this.assetMap); } module.exports = AssetRev;