Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

NodeEnvironmentPlugin.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const NodeWatchFileSystem = require("./NodeWatchFileSystem");
  7. const NodeOutputFileSystem = require("./NodeOutputFileSystem");
  8. const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
  9. const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
  10. const createConsoleLogger = require("../logging/createConsoleLogger");
  11. const nodeConsole = require("./nodeConsole");
  12. class NodeEnvironmentPlugin {
  13. constructor(options) {
  14. this.options = options || {};
  15. }
  16. apply(compiler) {
  17. compiler.infrastructureLogger = createConsoleLogger(
  18. Object.assign(
  19. {
  20. level: "info",
  21. debug: false,
  22. console: nodeConsole
  23. },
  24. this.options.infrastructureLogging
  25. )
  26. );
  27. compiler.inputFileSystem = new CachedInputFileSystem(
  28. new NodeJsInputFileSystem(),
  29. 60000
  30. );
  31. const inputFileSystem = compiler.inputFileSystem;
  32. compiler.outputFileSystem = new NodeOutputFileSystem();
  33. compiler.watchFileSystem = new NodeWatchFileSystem(
  34. compiler.inputFileSystem
  35. );
  36. compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
  37. if (compiler.inputFileSystem === inputFileSystem) inputFileSystem.purge();
  38. });
  39. }
  40. }
  41. module.exports = NodeEnvironmentPlugin;