Browser-sync: How to ignore node_modules ?

Created on 9 May 2016  路  2Comments  路  Source: BrowserSync/browser-sync

I can't figure out what configuration to use here, to ignore the node_modules folder. Currently if I install a new package the browser-sync reacts to hundreds of new files.

I'm proxying HarpJS with the following file; harp serves from the /public directory.

API documentation mentions two patterns for ignoring files but I've tried both with no success.

.
|-- node_modules
|-- private
`-- public

And my file looks like this

var bs = require('browser-sync').create();

bs.init({
  notify: false,
  proxy: "localhost:9000",
  browser: ["google chrome canary"],
  watchOptions: {
    ignoreInitial: true,
    ignored: ['./node_modules']
  },
  files: [
    './public/**/*.js',
    './public/**/*.jade',
    './public/**/*.md',
    './**/*.json',
    {
      match: './public/**/*.scss',
      fn: function (event, file) {
        if (event === 'change') {
          bs.reload(['local.css', '/assets/stylesheets/app.css']);
        }
      }
    }
  ]
});

Most helpful comment

Change your watchOptions to

watchOptions: {
    ignoreInitial: true,
    ignored: ['node_modules']
  },

tested this locally and it works as you expect :)

All 2 comments

Change your watchOptions to

watchOptions: {
    ignoreInitial: true,
    ignored: ['node_modules']
  },

tested this locally and it works as you expect :)

Thanks @shakyShane !

Was this page helpful?
0 / 5 - 0 ratings