Skip to content

Instantly share code, notes, and snippets.

@vgoma
Last active March 28, 2021 11:27
Show Gist options
  • Save vgoma/4d33c2937447afd2fb9ae2ef781761f9 to your computer and use it in GitHub Desktop.
Save vgoma/4d33c2937447afd2fb9ae2ef781761f9 to your computer and use it in GitHub Desktop.
Configuring webpack dev server watch inside docker container on OSX 10.12.5 (Sierra)

Configuring webpack dev server watch inside docker container on OSX 10.12.5 (Sierra)

The problem

When running webpack dev server from inside of docker container dev server says that it watching files, but don't react on changes in hosts filesystem. It also can actually react and recompile bundle but stream not updated files to the browser.

Solution

Some of this steps might not needed, but it was long run googling for complete solution

If you're using Webstorm or Phpstorm etc. Try disable "safe write" option in settings: Appearance & Behaviour -> System Settings -> Use "safe write" ...

Enable webpack polling:

config.devServer = {
    // Enable polling
    watchOptions: {
        poll: 1000,
        aggregateTimeout: 1000
    },
    
    // I also don't use these two:
    hot: false,
    inline: false
};

Karma config:

webpackMiddleware: {
    watchOptions: {
        poll: true
    }
}

Increase max open files limit in OS:

sudo launchctl limit maxfiles unlimited unlimited

sudo launchctl limit maxfiles

use your maxfiles value here also (1024 in my case):

ulimit -n 1024

then:

brew update
brew install watchman

finally you can specify your value in docker-compose.yml on service level

ulimits:
  nofile:
    soft: 10240
    hard: 10240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment