|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
756 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2018 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | import crypto from 'crypto';
|
|---|
| 10 | import type {Asset} from 'webpack';
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * @param {Asset} asset
|
|---|
| 14 | * @return {string} The MD5 hash of the asset's source.
|
|---|
| 15 | *
|
|---|
| 16 | * @private
|
|---|
| 17 | */
|
|---|
| 18 | export function getAssetHash(asset: Asset): string | null {
|
|---|
| 19 | // If webpack has the asset marked as immutable, then we don't need to
|
|---|
| 20 | // use an out-of-band revision for it.
|
|---|
| 21 | // See https://github.com/webpack/webpack/issues/9038
|
|---|
| 22 | if (asset.info && asset.info.immutable) {
|
|---|
| 23 | return null;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | return crypto.createHash('md5')
|
|---|
| 27 | .update(Buffer.from(asset.source.source()))
|
|---|
| 28 | .digest('hex');
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.