AddManagedPathsPlugin.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("../Compiler")} Compiler */
  7. class AddManagedPathsPlugin {
  8. /**
  9. * Creates an instance of AddManagedPathsPlugin.
  10. * @param {Iterable<string | RegExp>} managedPaths list of managed paths
  11. * @param {Iterable<string | RegExp>} immutablePaths list of immutable paths
  12. * @param {Iterable<string | RegExp>} unmanagedPaths list of unmanaged paths
  13. */
  14. constructor(managedPaths, immutablePaths, unmanagedPaths) {
  15. this.managedPaths = new Set(managedPaths);
  16. this.immutablePaths = new Set(immutablePaths);
  17. this.unmanagedPaths = new Set(unmanagedPaths);
  18. }
  19. /**
  20. * Applies the plugin by registering its hooks on the compiler.
  21. * @param {Compiler} compiler the compiler instance
  22. * @returns {void}
  23. */
  24. apply(compiler) {
  25. for (const managedPath of this.managedPaths) {
  26. compiler.managedPaths.add(managedPath);
  27. }
  28. for (const immutablePath of this.immutablePaths) {
  29. compiler.immutablePaths.add(immutablePath);
  30. }
  31. for (const unmanagedPath of this.unmanagedPaths) {
  32. compiler.unmanagedPaths.add(unmanagedPath);
  33. }
  34. }
  35. }
  36. module.exports = AddManagedPathsPlugin;