简体   繁体   中英

How to ignore with nodemon everything except a folder and an specific file?

I have this folder structure

.
├── admin/
│   └── ...
└── services/
    ├── user/
    │   ├── main.js
    │   └── model.js
    └── post/
        ├── main.js
        └── model.js

And this script in package.json

  "scripts": {
    "admin": "nodemon src/admin/ --exec babel-node",
  },

I want to restart the process only when something inside admin/ changes or when a file called model.js outside of the admin folder changes.

How I can achieve this?

You can create a nodemon.json file in the root of your project and then add the folders/files to watch in the watch property. nodemon.json will be used as the config for nodemon. You can also ignore files/folders as well.

{
  "ignore": [
    "services/*.js",
    "services/**/*.js"
  ],
  "watch": [
    "admin/*",
    "model.js"
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM