123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- "use strict";
- const CachedInputFileSystem = require("enhanced-resolve").CachedInputFileSystem;
- const fs = require("graceful-fs");
- const createConsoleLogger = require("../logging/createConsoleLogger");
- const NodeWatchFileSystem = require("./NodeWatchFileSystem");
- const nodeConsole = require("./nodeConsole");
- class NodeEnvironmentPlugin {
-
- constructor(options) {
- this.options = options;
- }
-
- apply(compiler) {
- const { infrastructureLogging } = this.options;
- compiler.infrastructureLogger = createConsoleLogger({
- level: infrastructureLogging.level || "info",
- debug: infrastructureLogging.debug || false,
- console:
- infrastructureLogging.console ||
- nodeConsole({
- colors: infrastructureLogging.colors,
- appendOnly: infrastructureLogging.appendOnly,
- stream:
-
- (infrastructureLogging.stream)
- })
- });
- compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
- const inputFileSystem =
-
- (compiler.inputFileSystem);
- compiler.outputFileSystem = fs;
- compiler.intermediateFileSystem = fs;
- compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
- compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
- if (
- compiler.inputFileSystem === inputFileSystem &&
- inputFileSystem.purge
- ) {
- compiler.fsStartTime = Date.now();
- inputFileSystem.purge();
- }
- });
- }
- }
- module.exports = NodeEnvironmentPlugin;
|