-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Detect --watch
mode reliably
#3460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I also need this for the elm-webpack-loader |
@sokra Maybe we can pass this in with a small plugin that leverages: 'normal-module-loader' hook from @s-panferov I'm going to test something and see if it works. There is a hook found in compilation.applyPlugins("normal-module-loader", loaderContext, this);
if(options.loader)
for(var key in options.loader)
loaderContext[key] = options.loader[key]; This adds information to the loaderContext. If @sokra agree's it's an okay direction maybe we can add a small plugin that detects whether |
Further research shows that it could be passed through to function apply(compiler) {
compiler.plugin('compilation', function(compilation) {
compilation.plugin('normal-module-loader', function(loaderContext, nmf) {
loaderContext.watch = compiler.options.watch;
});
});
} But again, I'll yield to @sokra to ensure this is an okay practice to use this hook. Otherwise we could try and implement it into core in |
@TheLarkInn the main point is how to make this without any plugins because they require more configuration from a user side. |
Also please note that you can't rely only on |
I'm saying internal implementation from core, IE new feature |
This would be a nice new feature. Typical webpack usage seems to be running webpack in watch mode when doing active development. Being able to easily detect this would allow customization of your webpack config. For example, if in watch mode then set |
I am using something like: export class WatchStateLoggerPlugin {
apply(compiler) {
compiler.plugin("watch-run", function(compiler, callback) {
isWatching = true;
}
}
} Hope it sounds reasonable. |
Closing due to inactivity. Please test with latest version and feel free to new create if still have problems/regressions. Thanks! |
Please reopen. This is a feature request and it is NOT solved. |
Pr welcome |
--watch
mode reliably --watch
mode reliably
@s-panferov you can detect the "watch" mode just by subscribing to "watchRun" and "watchClose" compiler hooks - so where is the problem? |
@TheAifam5 I just want to be able to understand this from a loader, without requiring user to install a compiler plugin just for this. |
@evilebottnawi and @TheLarkInn looks like this still open, I would like to help with this, can you guys point out where can I start? |
@renatoagds |
@evilebottnawi pretty thanks! I'll work on this one. |
@evilebottnawi added the flag at #8253. can you take a look? 👍 |
Uh oh!
There was an error while loading. Please reload this page.
Hi @sokra. I'm making https://github.com/s-panferov/awesome-typescript-loader and I need some way to detect if webpack is working in
--watch
mode or not (without plugins). I need this because I need to know if I should kill a spawnedchild_process
or not.Right now I'm doing something like:
But in doesn't seems to work in the latest
webpack@beta
. Can you please advise some reliable solution?Right now the only way I see is to use a compiler plugin:
The text was updated successfully, but these errors were encountered: