dev.writeToDisk

  • Type: boolean | ((filename: string) => boolean)
  • Default: false

Controls whether the build output from development mode is written to disk.

TIP

In development mode, Rsbuild stores the build outputs in memory on the dev server by default, rather than writing then to disk. This can reduce the overhead of fs operations. You can refer to View Static Assets to view all static assets generated in the current build.

Writing to Disk

You can choose to write the build output to disk, which is usually used for inspecting the content of the build output or configuring proxy rules for static assets.

Simply set the dev.writeToDisk option to true:

export default {
  dev: {
    writeToDisk: true,
  },
};
TIP

Setting writeToDisk: true is used for viewing the build output from development mode. It does not change the behavior of the dev server. When accessing files through a browser, the dev server will still read the file content from memory.

Matching Specific Files

You can also set dev.writeToDisk to a function to match only certain files. When the function returns false, the file will not be written; when it returns true, the file will be written to disk.

For example, to write files to disk while excluding hot-update temporary files:

export default {
  dev: {
    writeToDisk: (file) => !file.includes('.hot-update.'),
  },
};