How to ignore a folder when using watch with webpack?

by darrion.kuhn , in category: Javascript , 7 months ago

How to ignore a folder when using watch with webpack?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , 7 months ago

@darrion.kuhn 

To ignore a folder when using watch with webpack, you can use the ignored option in the watchOptions configuration.


Here's an example of how to ignore a folder named "node_modules":

1
2
3
4
5
6
7
8
9
// webpack.config.js

module.exports = {
  watch: true,
  watchOptions: {
    ignored: /node_modules/
  },
  // other webpack configurations...
};


In this example, we use a regular expression to match the folder name "node_modules" and ignore it when webpack is watching for changes. You can customize the regular expression to match any folder or file you want to ignore.