Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running webpack with watch in Bash on Ubuntu on Windows builds once and exits

Is there some way to get webpack --watch to work on Bash on Ubuntu on Windows?

I am running Ubuntu on Windows and webpack --watch runs once and exits, without errors, as if I simply ran only webpack.

Increasing the inotify file watch limit doesn't work; in /etc/sysctl.conf I have fs.inotify.max_user_watches=524288.

Update: Adding the following to my webpack.config.js file works:

watch: true,
watchOptions: {
  poll: true,
  aggregateTimeout: 300,
  number: 1000
}

But it causes my CPU usage to spike to 100%, making this solution impractical.

Update 2: There might be some more useful info on the issue here: https://github.com/webpack/webpack-dev-server/issues/155. However, I've switched to working on a Mac and this problem no longer affects me.

like image 952
chipit24 Avatar asked Nov 09 '22 10:11

chipit24


1 Answers

Looks like you're running Windows 10 Anniversary Update which didn't yet support INOTIFY file-change event notifications. This capability was added in Insider build 14942 back in Oct 2016:

https://blogs.msdn.microsoft.com/commandline/2016/10/07/wsl-adds-inotify-filesystem-change-notification-support/

Once you upgrade to a recent Insider build, or to Creators Update which will be released this spring, you'll be able to enjoy INOTIFY support which is more efficient than the polling mechanism that your config change enabled.

HTH.

like image 134
Rich Turner Avatar answered Jan 04 '23 02:01

Rich Turner