Search code examples
javascriptember-cliwatchman

Configuring watchman in ember-cli


In my ember-cli app, .watchman config file, I've mentioned what directories to ignore while watching, like "ignore_dirs": ["tmp"]. Now I want to watch files in a directory which is outside my app directory. Is there any way to do it?


Solution

  • If you had an ember project called my-ember-app in which the directory structure would typically look something like this:

    my-ember-app
     .watchmanconfig
     -- app
     -- bower_components
     -- config
     -- dist
     -- node_modules
     -- public
     -- tests
     -- tmp
     -- vendor
    

    and if you wanted watchman to not only ignore changes in the tmp but also in the sibling folder public, your .watchmanconfig file would have to look like this:

    {
      "ignore_dirs": ["tmp","public"]
    }
    

    You can find out more about the ignore_dirs option value of the .watchmanconfig file in the documentation.


    If that isn't working in your setup yet, make also sure that

    Watchman is actually installed.

    Ember CLI doesn't come with watchman out of the box, so you will have to install this additionally. If you notice this message showing up in your terminal once you spin up your ember app with ember serve:

    Could not find watchman, falling back to NodeWatcher for file system events Livereload server on http://localhost:49152 Serving on http://localhost:4200/

    watchman is not installed yet. On OSX you can install Watchman using Homebrew: brew install watchman and installation instructions for other OS'es can be found in the Watchman documentation.

    the watch for your project is removed and readded after editing .watchmanconfig.

    As stated in the documentation, watchman doesn't pick up on changes in your .watchmanconfig file automatically. For your new configuration to take any effect, move to the root of your ember project

    cd my-ember-app

    to first remove the watch

    watchman watch-del .

    and then re-add the watch

    watchman watch .

    You can check if the changes have been recognised by watchman correctly by using the command watchman get-config .