You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rsbuild-plugin-workspace-dev is designed for monorepo development. It computes the dependency graph starting from the current project and starts sub-projects in topological order.
When you run pnpm dev under app, sub-projects start in topological order: first lib1 and lib3, then lib2, and finally app. Starting a lib refers to running its dev command, for example:
{
"scripts": {
"dev": "rslib build --watch"
}
}
Whether a sub-project has finished starting is determined by matching sub-project logs. By default, logs from Rslib and tsup sub-projects are recognized. You can also provide a custom match function to determine when a sub-project is ready.
Options
projects
Configure how sub-projects are started and define custom log matching logic.
Type:
type projects = {
// The key is the name of the sub-project's package.json file.
[key: string]: Projects;
}
interface projects {
/**
* Custom sub-project start command. Default is `dev` (runs `npm run dev`).
*/
command?: string;
/**
* Custom logic to detect when a sub-project has started.
* By default, logs from `Rsbuild` and `tsup` are supported.
*/
match?: (stdout: string) => boolean;
/**
* Whether to skip starting the current sub-project. The default value is `false`, typically used to skip sub-projects that don't need to be started.
* When the value is `true`, pruning will be performed on the specified project, meaning that this project and all its direct and indirect dependencies will not be started by the plugin.
* When the value is `only`, starting the specified project will be skipped, but no pruning will be performed, meaning that the project's direct and indirect dependencies will still be started by the plugin.
*/
skip?: boolean | 'only';
}
// For example, to configure lib1 sub-project to use build:watch command and match watch success log
pluginWorkspaceDev({
projects: {
lib1: {
command: 'build:watch',
match: (stdout) => stdout.includes('watch success'),
},
},
})
startCurrent
Type: boolean
Default: false
Whether to also start the current project. The default is false. In most cases, you start the current project manually, so the plugin does not interfere.
Consider a scenario where docs and lib are in the same project, and docs needs to debug the output of lib. In this case, you want to run pnpm doc for the docs, while lib should run pnpm dev. After configuring this option in your Rspress config, starting pnpm doc will automatically run pnpm dev to start the lib sub-project.
Set the current working directory. The default is the current project directory; usually no configuration is needed.
workspaceFileDir
Type: string
Default: process.cwd()
Set the directory where the workspace file resides. The default is the current project directory; usually no configuration is needed.
Frequently Asked Questions
Project startup stuck
Stuck may be due to slow sub-project builds, etc. The lack of log output is because, by default, sub-project logs are output all at once after startup (to avoid interleaving sub-project logs). You can enable debug mode by adding an environment variable, which will allow sub-project logs to be output in real time.
DEBUG=rsbuild pnpm dev
Some projects don't need to start
If some sub-projects don't need to start, simply configure skip: true for the specified project in rsbuild.config.ts.