| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var NodeWatchFileSystem = require("./NodeWatchFileSystem"); | 
					
						
							|  |  |  | var NodeOutputFileSystem = require("./NodeOutputFileSystem"); | 
					
						
							|  |  |  | var NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem"); | 
					
						
							|  |  |  | var CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-21 03:40:58 +08:00
										 |  |  | function NodeEnvironmentPlugin() { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | module.exports = NodeEnvironmentPlugin; | 
					
						
							|  |  |  | NodeEnvironmentPlugin.prototype.apply = function(compiler) { | 
					
						
							|  |  |  | 	compiler.inputFileSystem = new NodeJsInputFileSystem(); | 
					
						
							| 
									
										
										
										
											2013-05-13 20:25:37 +08:00
										 |  |  | 	var inputFileSystem = compiler.inputFileSystem = new CachedInputFileSystem(compiler.inputFileSystem, 60000); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	compiler.resolvers.normal.fileSystem = compiler.inputFileSystem; | 
					
						
							|  |  |  | 	compiler.resolvers.context.fileSystem = compiler.inputFileSystem; | 
					
						
							|  |  |  | 	compiler.resolvers.loader.fileSystem = compiler.inputFileSystem; | 
					
						
							|  |  |  | 	compiler.outputFileSystem = new NodeOutputFileSystem(); | 
					
						
							|  |  |  | 	compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem); | 
					
						
							| 
									
										
										
										
											2013-05-13 20:25:37 +08:00
										 |  |  | 	compiler.plugin("run", function(compiler, callback) { | 
					
						
							|  |  |  | 		if(compiler.inputFileSystem === inputFileSystem) | 
					
						
							|  |  |  | 			inputFileSystem.purge(); | 
					
						
							|  |  |  | 		callback(); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | }; |