CC 4.0 License

The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.

The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.

Watch

Rspack can watch files and recompile whenever they change.

watch

  • Type: boolean
  • Default: false

Turn on watch mode. This means that after the initial build, Rspack will continue to watch for changes in any of the resolved files.

rspack.config.js
module.exports = {
  // ...
  watch: true,
};
TIP

In @rspack/dev-server watch mode is enabled by default.

watchOptions

  • Type: object

A set of options used to customize watch mode.

rspack.config.js
module.exports = {
  // ...
  watchOptions: {
    ignored: /node_modules/,
    poll: true,
  },
};

watchOptions.aggregateTimeout

  • Type: number
  • Default: 5

Add a delay before rebuilding once the first file changed. This allows Rspack to aggregate any other changes made during this time period into one rebuild. Pass a value in milliseconds:

rspack.config.js
module.exports = {
  //...
  watchOptions: {
    aggregateTimeout: 600,
  },
};

watchOptions.ignored

  • Type: RegExp, string, string[]

The path that matches is excluded while watching.

watchOptions.poll

  • Type: boolean, number
  • Default: false

Whether to watch by polling, the default polling interval for true is 5007 milliseconds.

  • Type: boolean

Follow symbolic links while looking for a file. This is usually not needed as Rspack already resolves symlinks with resolve.symlinks.

rspack.config.js
module.exports = {
  //...
  watchOptions: {
    followSymlinks: true,
  },
};

watchOptions.stdin

  • Type: boolean

Stop watching when stdin stream has ended.

rspack.config.js
module.exports = {
  //...
  watchOptions: {
    stdin: true,
  },
};