type CleanDistPath = boolean | 'auto' | CleanDistPathObject;'auto'Configure whether to clean all files in the output directory before the build starts. The output directory is the output.distPath.root directory.
The default value of output.cleanDistPath is 'auto':
false, Rsbuild will not perform cleanup.export default {
output: {
distPath: {
root: '../../some-dir',
},
},
};Set cleanDistPath to true to force enable it, or false to force disable it.
export default {
output: {
cleanDistPath: true,
},
};To clean files only in production mode and not in development mode, configure it as:
export default {
output: {
cleanDistPath: process.env.NODE_ENV === 'production',
},
};output.cleanDistPath supports configuration as an object to achieve more granular control.
boolean | 'auto''auto'Whether to clean up all files in the output directory before the build starts.
export default {
output: {
// Equivalent to `cleanDistPath: true`
cleanDistPath: {
enable: true,
},
},
};RegExp[]undefinedSpecify the files to keep in the output directory. If the file's absolute path matches the regular expression in keep, the file will not be removed.
For example, to keep the dist/foo.json file:
export default {
output: {
cleanDistPath: {
keep: [/dist\/foo.json/],
},
},
};