'NuxtJS ignore webpack/chokidar watchers for specific file or folder

I'm using NuxtJS' serverMiddleware for logging. It works on every route.

import { logger } from './utils/logger';
module.exports = function(req, res, next){
    logger.info('log.js');
    next();
}

It works fine, but when im working on dev environment, whenever I navigate some page, it logs some data, Nuxt dev server logs to console: Updated logs/server.log and then rebuilds dev server.

I need to extract them from watching list.

I've configured watchers property on nuxt.config.js ( according to this page: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-watchers) :

watchers: {
    chokidar: {
      ignored: '/logs/server.log'
    },
    webpack: {
      ignored: '/logs/server.log'
    }
  },

but unfortunately it doesn't work.

Thank you for your interest!

Edit

I've tried adding files to .nuxtignore file. But it doesn't work as well.



Solution 1:[1]

you could create a .nuxtignore file and add your file to it. I think this will help ignoring it all the way down.

More info here: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-ignore#nuxtignore

Solution 2:[2]

If you look at the documentation of the configuration-watcher you will find a link to the documentation and syntax needed by chokidar.ignored and webpack.ignored. (Basically use a regexp for a partial match on the path.)

THis should work:

watchers: {
    chokidar: { ignored: /logs\/server.log/ },
    webpack: { ignored: /logs\/server.log/ } },

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kissu
Solution 2 flowrakis