AssetsOverSizeLimitWarning.js 818B

123456789101112131415161718192021222324
  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. super();
  11. this.name = "AssetsOverSizeLimitWarning";
  12. this.assets = assetsOverSizeLimit;
  13. const assetLists = this.assets.map(asset => `\n ${asset.name} (${SizeFormatHelpers.formatSize(asset.size)})`).join("");
  14. this.message = `asset size limit: The following asset(s) exceed the recommended size limit (${SizeFormatHelpers.formatSize(assetLimit)}).
  15. This can impact web performance.
  16. Assets: ${assetLists}`;
  17. Error.captureStackTrace(this, this.constructor);
  18. }
  19. };