source: imaps-frontend/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const CachedInputFileSystem = require("enhanced-resolve").CachedInputFileSystem;
9const fs = require("graceful-fs");
10const createConsoleLogger = require("../logging/createConsoleLogger");
11const NodeWatchFileSystem = require("./NodeWatchFileSystem");
12const nodeConsole = require("./nodeConsole");
13
14/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
15/** @typedef {import("../Compiler")} Compiler */
16/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
17
18class NodeEnvironmentPlugin {
19 /**
20 * @param {object} options options
21 * @param {InfrastructureLogging} options.infrastructureLogging infrastructure logging options
22 */
23 constructor(options) {
24 this.options = options;
25 }
26
27 /**
28 * Apply the plugin
29 * @param {Compiler} compiler the compiler instance
30 * @returns {void}
31 */
32 apply(compiler) {
33 const { infrastructureLogging } = this.options;
34 compiler.infrastructureLogger = createConsoleLogger({
35 level: infrastructureLogging.level || "info",
36 debug: infrastructureLogging.debug || false,
37 console:
38 infrastructureLogging.console ||
39 nodeConsole({
40 colors: infrastructureLogging.colors,
41 appendOnly: infrastructureLogging.appendOnly,
42 stream:
43 /** @type {NodeJS.WritableStream} */
44 (infrastructureLogging.stream)
45 })
46 });
47 compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
48 const inputFileSystem =
49 /** @type {InputFileSystem} */
50 (compiler.inputFileSystem);
51 compiler.outputFileSystem = fs;
52 compiler.intermediateFileSystem = fs;
53 compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
54 compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
55 if (
56 compiler.inputFileSystem === inputFileSystem &&
57 inputFileSystem.purge
58 ) {
59 compiler.fsStartTime = Date.now();
60 inputFileSystem.purge();
61 }
62 });
63 }
64}
65
66module.exports = NodeEnvironmentPlugin;
Note: See TracBrowser for help on using the repository browser.