You can use the root config to set workspace configs in bulk by using workspace patterns.
Entries' configs will be merged with any existing workspaces' local configs, and each subsequent entry's config will be merged with
the accumulated config from any similarly matching previous entries, using
the same behavior as mergeWorkspaceConfig.
Since workspace patterns are affected by config, such as using tags, each entry's patterns will match against the accumulated config from the previous entries.
// bw.root.ts
import { defineRootConfig } from "bun-workspaces/config";
export default defineRootConfig({
workspacePatternConfigs: [
{
// Any matching workspaces under this path
// will have their local config merged with this one
patterns: ["path:libraries/frontend/**/*"],
config: {
tags: ["frontend"],
},
},
{
patterns: ["path:libraries/backend/**/*"],
config: {
tags: ["backend"],
},
},
{
// This tag can be matched thanks to the first entry,
// merging the accumulated config with this one
patterns: ["tag:frontend"],
config: {
rules: {
workspaceDependencies: {
denyPatterns: ["tag:backend"],
},
},
},
},
{
patterns: ["tag:backend"],
// You can use the raw workspace data and
// accumulated config for each workspace via callback
config: (workspace, prevConfig) => ({
rules: {
workspaceDependencies: workspace.name.startsWith("@some-scope/")
? {
denyPatterns: ["@some-other-scope/*"],
}
: {
allowPatterns: ["@some-scope/*"],
}
},
}),
}
],
});