Cannot disable --watch mode
waweber opened this issue · 5 comments
Bug report
Actual Behavior
It doesn't seem to be possible to disable --watch mode when running webpack serve
:
- setting
watch: false
in webpack config does not disable --watch behavior - setting
devServer.watchFiles
config to{}
or[]
does not stop recompilation - setting
devServer.watchFiles.paths
to[]
or["asdf"]
does not stop recompilation - running
webpack serve --watch-files-reset
does not stop recompilation - running
webpack serve --watch-files-reset --watch-files asdf
does not stop recompilation
This makes it very tedious to test PWA/service workers e.g. when using Workbox, as the service worker's pre-cache manifest will be incorrect after recompilation.
Expected Behavior
Webpack should not notice changes to files or recompile any bundles, or ideally accept some sort of --no-watch parameter.
How Do We Reproduce?
Take an example project and attempt any of the configuration settings above, then edit some files.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Linux 5.15 Fedora Linux 35 (KDE Plasma)
CPU: (8) x64 AMD Ryzen 5 1500X Quad-Core Processor
Memory: 7.91 GB / 15.61 GB
Binaries:
Node: 16.13.2 - /usr/bin/node
npm: 8.1.2 - /usr/bin/npm
Browsers:
Chrome: 97.0.4692.99
Firefox: 96.0
Packages:
babel-loader: ^8.2.3 => 8.2.3
css-loader: ^6.5.1 => 6.5.1
html-webpack-plugin: ^5.5.0 => 5.5.0
svgo-loader: ^3.0.0 => 3.0.0
webpack: ^5.68.0 => 5.68.0
webpack-cli: ^4.9.2 => 4.9.2
webpack-dev-server: ^4.7.3 => 4.7.3
workbox-webpack-plugin: ^6.4.2 => 6.4.2
--no-watch
already exists.
@snitin315 for webpack itself, yes, but dev-server does not seem to accept/forward the setting:
$ npx webpack serve --no-watch
[webpack-cli] Error: Unknown option '--no-watch'
Issue in webpack-cli
It seems this is intentional because webpack-dev-server will always watch for files.
webpack-cli/packages/serve/src/index.ts
Lines 73 to 77 in 2ca104f
Yes, --watch
and --no-watch
is not supported for dev server, dev server always watches files