webpack/lib/node/NodeEnvironmentPlugin.js

23 lines
965 B
JavaScript
Raw Normal View History

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) {
if(compiler.inputFileSystem === inputFileSystem)
inputFileSystem.purge();
callback();
});
};