How to ignore a folder when using watch with webpack?

by darrion.kuhn , in category: Javascript , a year ago

How to ignore a folder when using watch with webpack?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , a year 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.

Related Threads:

How to ignore typescript errors with webpack?
How to use webpack to ignore a module?
How to make webpack ignore library dependencies?
How to achieve "insert ignore" using presto?
How to ignore timezone when parsing using moment.js?
How to ignore white space in string using regex?