AssetsOverSizeLimitWarning.js 922 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Sean Larkin @thelarkinn
  4. */
  5. "use strict";
  6. const { formatSize } = require("../SizeFormatHelpers");
  7. const WebpackError = require("../WebpackError");
  8. /** @typedef {import("./SizeLimitsPlugin").AssetDetails} AssetDetails */
  9. module.exports = class AssetsOverSizeLimitWarning extends WebpackError {
  10. /**
  11. * @param {AssetDetails[]} assetsOverSizeLimit the assets
  12. * @param {number} assetLimit the size limit
  13. */
  14. constructor(assetsOverSizeLimit, assetLimit) {
  15. const assetLists = assetsOverSizeLimit
  16. .map(asset => `\n ${asset.name} (${formatSize(asset.size)})`)
  17. .join("");
  18. super(`asset size limit: The following asset(s) exceed the recommended size limit (${formatSize(
  19. assetLimit
  20. )}).
  21. This can impact web performance.
  22. Assets: ${assetLists}`);
  23. this.name = "AssetsOverSizeLimitWarning";
  24. this.assets = assetsOverSizeLimit;
  25. }
  26. };