I am using chokidar to watch files ending with (.js|.jsx|.scss) as below, but RegEx does not work. if just run /^(?!.*(?:\.jsx?|\.scss)$).*$/
, it works fine.
const watcher = chokidar.watch('./app', {
ignored: /^(?!.*(?:\.jsx?|\.scss)$).*$/,
ignoreInitial: true,
persistent: true
})
chokidar watches files, also watches paths. So /^(?!.*(?:\.jsx?|\.scss)$).*$/
would ignore files not ending with .js/jsx/.scss but also all paths. To resolve this problem, I use below RegEx:
/^(?=.*(\.\w+)$)(?!.*(?:\.jsx?|\.scss)$).*$/