WarnNoModeSetPlugin.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const WebpackError = require("./errors/WebpackError");
  7. class NoModeWarning extends WebpackError {
  8. constructor() {
  9. super();
  10. /** @type {string} */
  11. this.name = "NoModeWarning";
  12. /** @type {string} */
  13. this.message =
  14. "configuration\n" +
  15. "The 'mode' option has not been set, webpack will fallback to 'production' for this value.\n" +
  16. "Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
  17. "You can also set it to 'none' to disable any default behavior. " +
  18. "Learn more: https://webpack.js.org/configuration/mode/";
  19. }
  20. }
  21. /** @import Compiler from "./Compiler" */
  22. const PLUGIN_NAME = "WarnNoModeSetPlugin";
  23. class WarnNoModeSetPlugin {
  24. /**
  25. * Applies the plugin by registering its hooks on the compiler.
  26. * @param {Compiler} compiler the compiler instance
  27. * @returns {void}
  28. */
  29. apply(compiler) {
  30. compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
  31. compilation.warnings.push(new NoModeWarning());
  32. });
  33. }
  34. }
  35. module.exports = WarnNoModeSetPlugin;