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");
|
|
|
|
|
2015-07-13 06:20:09 +08:00
|
|
|
function NodeEnvironmentPlugin() {}
|
2013-01-31 01:49:25 +08:00
|
|
|
module.exports = NodeEnvironmentPlugin;
|
|
|
|
NodeEnvironmentPlugin.prototype.apply = function(compiler) {
|
2016-12-05 06:47:19 +08:00
|
|
|
compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
|
|
|
|
var inputFileSystem = compiler.inputFileSystem;
|
2013-01-31 01:49:25 +08:00
|
|
|
compiler.outputFileSystem = new NodeOutputFileSystem();
|
|
|
|
compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
|
2016-05-07 04:45:44 +08:00
|
|
|
compiler.plugin("before-run", function(compiler, callback) {
|
2015-07-16 06:19:23 +08:00
|
|
|
if(compiler.inputFileSystem === inputFileSystem)
|
2013-05-13 20:25:37 +08:00
|
|
|
inputFileSystem.purge();
|
|
|
|
callback();
|
|
|
|
});
|
2015-07-08 20:39:02 +08:00
|
|
|
};
|