Skip to content

Add option to make watchContentBase recursive or expose chokidar options #1694

Description

@marcofugaro
  • Operating System: OSX

  • Node Version: v11.7.0

  • NPM Version: 6.5.0

  • webpack Version: 4.29.5

  • webpack-dev-server Version: 3.2.1

  • This is a bug

  • This is a modification request

Code

I have a public folder like this

public/
├── assets
│   ├── image.png
│   ├── video.mp4
├── css
│   └── style.css
└── index.html

And my config like this

devServer: {
  publicPath: '/',
  contentBase: './public/',
  watchContentBase: true,
  // don't watch node_modules
  watchOptions: {
    ignored: /node_modules/,
  },
},

Actual Behavior

Right now the watchContentBase acts only on the root folder, because of this chokidar options:

Expected Behavior

I would like for watchContentBase: true, to trigger a reload whenever a file in my public folder changes.

It was also discussed in #1227, but I don't this is a good solution to start another chokidar instance. Plus this is a really common use-case.

It would be really useful to have an option recursive: true in the watchOptions: {}, or more simply a depth: undefined option which goes to override the default chokidar options.

I am willing to make a PR if we decide what direction to take.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions