ember-cli / broccoli-asset-rev

Broccoli plugin to add fingerprint checksums and CDN URLs to your assets
MIT License
87 stars 84 forks source link

JSON file with same name as JS file is fingerprinted in code but not on disk, if 'json' not in extensions to process #94

Open djmitchella opened 8 years ago

djmitchella commented 8 years ago

Repro steps:

npm install --save broccoli
npm install --save broccoli-asset-rev
mkdir app
echo "hello" > app/test.js
echo "there" > app.test.json

Create app/index.html containing

<script src="test.js">
<script src="test.json">

Create Brocfile.js containing:

var AssetRev = require('broccoli-asset-rev');
var assetNode = new AssetRev('app', {});
module.exports = assetNode;

Run broccoli build dist

Now, look in the 'dist' folder. It contains

test-b1946ac92492d2347c6235b4d2611184.js
test.json

so you can see that test.js has been fingerprinted, and test.json has not. This is reasonable, the default file extensions for broccoli-asset-rev contains "js" but not "json".

Now look inside dist/index.html. It contains:

<script src="test-b1946ac92492d2347c6235b4d2611184.js">
<script src="test-b1946ac92492d2347c6235b4d2611184.json">

Notice that it has replaced the reference to test.json with the same fingerprint that it used for test.js, even though a:test.json should have a different fingerprint as it has different contents, and b:the test.json file in the 'dist' folder didn't get renamed, so the reference shouldn't have changed.

If I add 'json' to the list of extensions to process in the options, then it starts to work properly.