get-asset-hash.js 458 B

123456789101112131415161718192021
  1. "use strict";
  2. /*
  3. Copyright 2018 Google LLC
  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. const crypto = require('crypto');
  9. /**
  10. * @param {WebpackAsset} asset
  11. * @return {string} The MD5 hash of the asset's source.
  12. *
  13. * @private
  14. */
  15. module.exports = asset => {
  16. return crypto.createHash('md5').update(Buffer.from(asset.source())).digest('hex');
  17. };