mirror of https://github.com/webpack/webpack.git
				
				
				
			
		
			
				
	
	
		
			30 lines
		
	
	
		
			960 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			960 B
		
	
	
	
		
			JavaScript
		
	
	
	
| /*
 | |
| 	MIT License http://www.opensource.org/licenses/mit-license.php
 | |
| 	Author Tobias Koppers @sokra
 | |
| */
 | |
| 
 | |
| "use strict";
 | |
| 
 | |
| const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
 | |
| const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
 | |
| const NodeOutputFileSystem = require("./NodeOutputFileSystem");
 | |
| const NodeWatchFileSystem = require("./NodeWatchFileSystem");
 | |
| 
 | |
| class NodeEnvironmentPlugin {
 | |
| 	apply(compiler) {
 | |
| 		compiler.inputFileSystem = new CachedInputFileSystem(
 | |
| 			new NodeJsInputFileSystem(),
 | |
| 			60000
 | |
| 		);
 | |
| 		const inputFileSystem = compiler.inputFileSystem;
 | |
| 		compiler.outputFileSystem = new NodeOutputFileSystem();
 | |
| 		compiler.watchFileSystem = new NodeWatchFileSystem(
 | |
| 			compiler.inputFileSystem
 | |
| 		);
 | |
| 		compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
 | |
| 			if (compiler.inputFileSystem === inputFileSystem) inputFileSystem.purge();
 | |
| 		});
 | |
| 	}
 | |
| }
 | |
| module.exports = NodeEnvironmentPlugin;
 |