Webpack --Watch Exits After Building Once

webpack --watch exits after building once

The problem seems to have arose because of the inotify watch limit

Listen uses inotify by default on Linux to monitor directories for
changes. It's not uncommon to encounter a system limit on the number
of files you can monitor.

The current watch limit can be seen through the command

$ cat /proc/sys/fs/inotify/max_user_watches

In my case it was 8192 which is the default value for linux X64 systems

To change it temporarily we need to run the following commands

$ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p

For permanently setting it we should run run

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

webpack --watch isn't compiling changed files

FYI: it seems OS X can have a folder get corrupted and no longer send fsevents (which watchpack/chokidar/Finder uses) for itself and any child folders. I can't be sure this is what happened to you, but it was very frustrating for me and a colleague.

We were able to rename the corrupt parent folder and then watch events immediately came through as expected. See this blog post for more info: http://livereload.com/troubleshooting/os-x-fsevents-bug-may-prevent-monitoring-of-certain-folders/

The recommended fixes from the above link are:

  • rebooting the computer
  • checking the disk and repairing permissions via Disk Utility
  • adding the folder to Spotlight privacy list (the list of folders to not index), and then removing from it, effectively forcing a reindexing
  • renaming the folder, and then possibly renaming it back
  • re-creating the folder and moving the old contents back into it

First two did not work for us, didn't try the Spotlight suggestion, and the re-creation did not prove necessary.

We were able to find the root problem folder by opening Finder and creating files in each successive parent folder until one showed up immediately (since Finder will get hosed by this bug as well). The root-most folder that does not update is the culprit. We just mv'd it and mv'd it back to its original name, and then the watcher worked.

No idea what causes the corruption, but I'm just glad to have a fix.

Why is webpack --watch not updating when specific files are updated

using the old watcher plugin seems to resolve the issue for my needs. Done in my configuration via:

plugins: [
new webpack.OldWatchingPlugin()
],

Webpack watch crashes after error in js-file

Got an answer - add after webpack's pipe

.on('error', function handleError() {
this.emit('end'); // Recover from errors
})

https://github.com/shama/webpack-stream/issues/34#issuecomment-171644957

Webpack builds successfully, but hangs without exiting

I figured out my problem. I use the same webpack config in dev and production. In dev, it's configured to watch for file changes and restart the server. I didn't realize that this also meant that it was watching for file changes in production ready to rebuild the bundle. Changing the line watch: true to watch: process.env.NODE_ENV !== 'production' && true fixed the issue.

webpack-dev-server does not watch for my file changes

you need to run webpack-dev-server with the --hot flag:

webpack-dev-server --content-base ./ --port 9966 --hot

Then you can access the hot-loading version localhost:9966/webpack-dev-server/

You don't need to run watch as well.

update:

This entry in your webpack config must change:

entry: ['./js/main.js'], --> entry: ['webpack/hot/dev-server' , './js/main.js']

Change your publicPath entry:

publicPath: '/assets/'



Related Topics



Leave a reply



Submit