[Feature]: Support clean distPath of DTS before build
What problem does this feature solve?
For js outputs, Rsbuild will automatically clean distPath, see more details https://rsbuild.dev/config/output/clean-dist-path#outputcleandistpath
And for DTS outputs, we should also support to control the behaviour of clean DTS distPath after below code:
https://github.com/web-infra-dev/rslib/blob/4b5f674789059bea3456e1105cb3cf9b051912d7/packages/plugin-dts/src/index.ts#L63
The default value of clean should directly read from output.cleanDistPath
- if it is false value, do not remove DTS distPath
- otherwise, just remove DTS distPath
Do we need a new option? How about always reading output.cleanDistPath.
Do we need a new option? How about always reading
output.cleanDistPath.
That seems better.
As a Rsbuild plugin, the DTS plugin could add a new config field, and defaults to Rsbuild's output.cleanDistPath while could be altered by user. In Rslib, we don't need to expose the config at the moment.
As a Rsbuild plugin, the DTS plugin could add a new config field, and defaults to Rsbuild's
output.cleanDistPathwhile could be altered by user. In Rslib, we don't need to expose the config at the moment.
Rsbuild plugin can directly read output.cleanDistPath, seems no need to add an extra options for rsbuild-plugin-dts