MinMaxSizeWarning.js 955 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const SizeFormatHelpers = require("../SizeFormatHelpers");
  7. const WebpackError = require("../WebpackError");
  8. class MinMaxSizeWarning extends WebpackError {
  9. /**
  10. * @param {string[] | undefined} keys keys
  11. * @param {number} minSize minimum size
  12. * @param {number} maxSize maximum size
  13. */
  14. constructor(keys, minSize, maxSize) {
  15. let keysMessage = "Fallback cache group";
  16. if (keys) {
  17. keysMessage =
  18. keys.length > 1
  19. ? `Cache groups ${keys.sort().join(", ")}`
  20. : `Cache group ${keys[0]}`;
  21. }
  22. super(
  23. `SplitChunksPlugin\n` +
  24. `${keysMessage}\n` +
  25. `Configured minSize (${SizeFormatHelpers.formatSize(minSize)}) is ` +
  26. `bigger than maxSize (${SizeFormatHelpers.formatSize(maxSize)}).\n` +
  27. "This seem to be a invalid optimization.splitChunks configuration."
  28. );
  29. }
  30. }
  31. module.exports = MinMaxSizeWarning;