Right now the version file gets written to disk even when running webpack-dev-server. That shouldn't be the case.
This seems to work just fine with Webpack 1 (seen here):
/**
* When 'webpack' program is used, constructor name is equal to 'NodeOutputFileSystem'.
* When 'webpack-dev-server' program is used, constructor name is equal to 'MemoryFileSystem'.
*/
const isMemoryFileSystem = (outputFileSystem: Object): boolean => {
return outputFileSystem.constructor.name === 'MemoryFileSystem';
};
if (!isMemoryFileSystem(compiler.outputFileSystem) && !options.force) {
return false;
}
Basically the plugin's apply method receives compiler as its first argument. In the function above:
outputFileSystem = compiler.outputFileSystem.constructor.name;
However it seems compiler.outputFileSystem.constructor.name is always NodeOutputFileSystem for Webpack 2.
More info on the compiler object on the official docs.
Could also use process.argv[1] to get the path to the file being executed, but this won't work if Webpack Dev Server gets executed from the CLI. Should try to use a combination of the two:
const isDevServer = process.argv[1].indexOf('webpack-dev-server') > -1 || someOtherCondition;
Right now the version file gets written to disk even when running
webpack-dev-server. That shouldn't be the case.This seems to work just fine with Webpack 1 (seen here):
Basically the plugin's
applymethod receivescompileras its first argument. In the function above:However it seems
compiler.outputFileSystem.constructor.nameis alwaysNodeOutputFileSystemfor Webpack 2.More info on the
compilerobject on the official docs.Could also use
process.argv[1]to get the path to the file being executed, but this won't work if Webpack Dev Server gets executed from the CLI. Should try to use a combination of the two: