3

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.

Muth
  • 43
  • 1
  • 4

2 Answers2

0

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

UPDATE: this solution may be quite better: https://stackoverflow.com/a/74052866/8816585

kissu
  • 40,416
  • 14
  • 65
  • 133
0

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/ } },
flowrakis
  • 11
  • 1