AssetsOverSizeLimitWarning.js 837 B

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