在ember-cli中配置watchman

Sat*_*san 6 javascript ember-cli watchman

在我的ember-cli app,.watchman配置文件中,我已经提到了在观看时要忽略的目录,比如"ignore_dirs": ["tmp"].现在我想在我的app目录之外的目录中查看文件.有什么办法吗?

jes*_*ica 5

如果您有一个 ember 项目my-ember-app,其中的目录结构通常如下所示:

my-ember-app
 .watchmanconfig
 -- app
 -- bower_components
 -- config
 -- dist
 -- node_modules
 -- public
 -- tests
 -- tmp
 -- vendor
Run Code Online (Sandbox Code Playgroud)

如果您希望 watchman 不仅忽略tmp同级文件夹中的更改,还忽略同级文件夹中的更改,则public您的.watchmanconfig文件必须如下所示:

{
  "ignore_dirs": ["tmp","public"]
}
Run Code Online (Sandbox Code Playgroud)

您可以在文档中找到有关文件ignore_dirs选项值的更多信息。.watchmanconfig


如果这在您的设置中还不起作用,请确保

守望者实际上已安装。

Ember CLI 没有开箱即用的 watchman,因此您必须另外安装它。如果您在使用ember serve以下命令启动 ember 应用程序后发现终端中显示此消息:

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

还没有安装watchman。在 OSX 上,您可以使用 Homebrew 安装 Watchman:brew install watchman其他操作系统的安装说明可以在Watchman 文档中找到。

编辑后删除并读取您项目的监视.watchmanconfig

如文档中所述,watchman 不会.watchmanconfig自动获取文件中的更改。要使新配置生效,请移至 ember 项目的根目录

cd my-ember-app

首先取下手表

watchman watch-del .

然后重新添加手表

watchman watch .

您可以使用以下命令检查 watchman 是否正确识别了更改 watchman get-config .