Skip to content

Commit

Permalink
fix: remove unused contentHash
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Dec 28, 2019
1 parent 7aad73d commit b48697f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ module.exports = class FaviconsWebpackPlugin {
}
const hash = crypto.createHash('sha256').update(content.toString('utf8')).digest('hex');
const outputPath = getAssetPath(compilation, this.options.prefix, {hash, chunk: {
hash: hash,
contentHash: hash
hash: hash
}});
const logoOutputPath = outputPath + (outputPath.substr(-1) === '/' ? '' : '/') + 'favicon' + faviconExt;
compilation.assets[logoOutputPath] = {
Expand Down
16 changes: 16 additions & 0 deletions test/prefixed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@ test('should allow configuring the output prefix', async t => {
snapshotCompilationAssets(t, compilationStats);
});

test('should allow configuring the output prefix for light mode', async t => {
const dist = path.join(t.context.root, 'dist');
const compilationStats = await generate({
context: t.context.root,
output: {
path: dist,
},
plugins: [
new HtmlWebpackPlugin(),
new FaviconsWebpackPlugin({ logo, prefix: 'custom/prefix/[hash:8]', mode: 'light' }),
],
});

snapshotCompilationAssets(t, compilationStats);
})

test.afterEach(t => fs.remove(t.context.root));
Binary file modified test/snapshots/html.false.test.js.snap
Binary file not shown.
Binary file modified test/snapshots/html.true.test.js.snap
Binary file not shown.
Binary file modified test/snapshots/light.test.js.snap
Binary file not shown.
24 changes: 24 additions & 0 deletions test/snapshots/prefixed.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,27 @@ Generated by [AVA](https://ava.li).
`,
},
]

## should allow configuring the output prefix for light mode

> Snapshot 1
[
'custom/prefix/7efef726/favicon.png',
'index.html',
'main.js',
]

> Snapshot 2
[
{
assetName: 'custom/prefix/7efef726/favicon.png',
content: 'binary',
},
{
assetName: 'index.html',
content: `<!doctype html><html><head><link rel="icon" href="/custom/prefix/7efef726/favicon.png"></head><body></body></html>␊
`,
},
]
Binary file modified test/snapshots/prefixed.test.js.snap
Binary file not shown.

0 comments on commit b48697f

Please sign in to comment.