remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.32k stars 1.73k forks source link

nodemon doesn't restart the process when watching multiple files #2013

Closed hrbonz closed 2 years ago

hrbonz commented 2 years ago

Versions:

Expected behaviour

Tailwind essentially takes 3 input files to render a CSS file:

The problem with tailwind watch is that it will only react to changes in content files so I want to use nodemon to restart a watch script when tailwind.config.js or tailwind.css change:

$ yarn nodemon --watch ./src/tailwind.css --watch ./tailwind.config.js --exec "yarn common:tailwind_watch"

The common:tailwind_watch script is defined in package.json:

{
  "scripts": {
    "common:tailwind_watch": "tailwindcss -i ./src/tailwind.css -o ./_build/css/style_common.css --watch"
  }
}

Actual behaviour

When using both watch declarations, nodemon won't do anything when change happens in the files watched. If I run nodemon to watch only one file (either file), then the process restarts properly.

I've tried adding -e css,js and -e css,config.js after reading an old issue but it doesn't change anything. I've used --dump to take a look at the result but I'm not quite comfortable enough with the content to detect any problem.

One way I got it to work is by "chaining" two nodemon each watching one file (nodemon watching tailwind.config.js -> nodemon watching tailwind.css -> yarn script) and that worked but is quite ugly.

Steps to reproduce

npm packages:

yarn add nodemon tailwindcss

I use yarn workspaces and Plug'n'Play inside a virtualenv with nodeenv (a python package that allows me to install node in virtualenv) if that could create any type of side effect.

Dump:

--------------    
node: v17.0.0      
nodemon: 2.0.16                                     
command: /**/.virtualenvs/flowviz/bin/node /***/frontend/.yarn/unplugged/nodemon-npm-2.0.16-f564cd587f/node_modules/nodemon/bin/nodemon.js --dump --watch ./src/tailwind.css --exec yarn common:tailwind_watch
cwd: /***/frontend/common
OS: linux x64            
--------------
{              
  run: false,                                       
  system: { cwd: '/***/frontend/common' },
  required: false, 
  dirs: [                
    '/***/frontend/common/src/tailwind.css',
    '/***/frontend/common/tailwind.config.js'
  ],
  timeout: 1000,                                    
  options: {                                        
    dump: true,  
    watch: [ 
      './src/tailwind.css',
      './tailwind.config.js',
      re: /\.\/src\/tailwind\.css|\.\/tailwind\.config\.js/
    ],                                                                                                   
    exec: 'yarn common:tailwind_watch', 
    ignore: [
      '**/.git/**',
      '**/.nyc_output/**', 
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**',
      re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
    ],
    monitor: [
      './src/tailwind.css',
      './tailwind.config.js',
      '!**/.git/**',
      '!**/.nyc_output/**',
      '!**/.sass-cache/**',
      '!**/bower_components/**',
      '!**/coverage/**',
      '!**/node_modules/**'
    ],
    ignoreRoot: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**'
    ],
    restartable: 'rs',
    colours: true,
    execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
    stdin: true,
    runOnChangeOnly: false,
    verbose: false,
    signal: 'SIGUSR2',
    stdout: true,
    watchOptions: {},
    execOptions: {
      script: null,
      exec: 'yarn common:tailwind_watch',
      args: [],
      scriptPosition: null,
      nodeArgs: undefined,
      execArgs: [],
      ext: 'js,mjs,json',
      env: {}
    }
  },
  load: [Function (anonymous)],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: {
    raw: { executable: 'yarn common:tailwind_watch', args: [] },
    string: 'yarn common:tailwind_watch'
  }
}
github-actions[bot] commented 2 years ago

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

github-actions[bot] commented 2 years ago

Automatically closing this issue due to lack of activity

olavarrieta commented 2 years ago

@hrbonz Did you ever get that work for you? I have a node express tailwindcss setup and I'm having the a similar issue where nodemon and tailwind are running and watching but tailwind ads the classes I use in my ejs files but doesn't remove them when I remove them from the ejs files. The only way that will happen is my stopping the process and running it again, then the tailwind cli scans the files and removes them on start up.

This is what my package.json file looks like: "scripts": { "start": "run-p server tailwind", "tailwind": "tailwindcss -i ./css/input.css -o ./public/output.css --watch --minify", "server": "nodemon server.js" },

hrbonz commented 2 years ago

Never got it to work, I had to split the monitoring of files and chain them which is quite ugly but works