Configuring the Workspace (workspace.jsonc)

The workspace.jsonc serves as the main configuration file for the workspace and its components.

workspace.jsonc is composed of a list of Bit aspects, and their corresponding configurations. For example, the following configuration is used to configure two Aspects:

  • teambit.workspace/workspace: The Workspace Aspect (responsible for the Workspace)
  • teambit.dependencies/dependency-resolver: The Dependency Resolver Aspect (responsible for dependency management)

Since each Aspect is a component, it uses the Component ID pattern.

{
  "teambit.workspace/workspace": {
    "name": "my-workspace",
    "defaultDirectory": "{scope}/{name}",
    "defaultScope": "company.scope"
  },
  "teambit.dependencies/dependency-resolver": {
    "packageManager": "teambit.dependencies/pnpm",
    "policy": {
      "dependencies": {
        "classnames": "2.3.1",
        "text-transform": "^0.1.2"
      }
    }
  }
}
CopiedCopy

The workspace configuration is extensible. It is not limited to a pre-configured list of Aspects.

teambit.workspace/workspace

teambit.workspace/workspace receives configurations for the workspace itself, as well as default values for components managed by the workspace.

name

name: string;
CopiedCopy

The name of the workspace. This name will be displayed in the workspace UI.

icon

icon: string;
CopiedCopy

Th path to an icon (svg, jpeg, etc.). The icon wll be displayed in the workspace UI.

defaultScope

defaultScope: string;
CopiedCopy

The default scope for all components in the workspace. This will be overridden by any other source of configuration, for example, variant.

defaultDirectory

defaultDirectory: string;
CopiedCopy

The default directory (relative path) to place a component during bit import and bit create.

The following placeholders are available:

  • name - the component full name
  • scopeId - the scope-id
  • scope - scope name
  • owner - owner name

For example:

{
  "defaultDirectory": "{scope}/{name}"
}
CopiedCopy

Resolve Aspects From Node Modules

resolveAspectsFromNodeModules: boolean;
CopiedCopy

Performance enhancement, ensures that aspects (components that interact with Bit) are loaded locally and not fetched from external directories (e.g. capsules).
This is defaulted to true for new workspaces.

Resolve Aspects From Node Modules

resolveEnvsFromRoots: boolean;
CopiedCopy

Performance enhancement, ensures that envs are loaded locally in the workspace and not stored externally (e.g. in a capsule).
This is defaulted to true for new workspaces.

Adding an aspect to the workspace

Aspects are fullstack components that implement the various features that make up Bit. Aspects are composed together by consuming each others services.

Your workspace already uses the services of a various of aspects. Add an aspect to your workspace to extend it with new features that add Bit commands, UI tabs, and so on.

For example, to use a custom aspect that extracts the 'todo' comments of components in that workspace, run the following commands:

Install the aspect's peer dependencies in your workspace:

$bit
Copiedcopy

Run the following to add the custom aspect to your workspace:

$bit
Copiedcopy

The output notifies the aspect was added to your workspace config:

aspect "learnbit.extending-bit/metadata/component-todos/component-todos" has been saved into the workspace.jsonc file.

Now that this aspect is added to your workspace, components in that workspace will have their 'todos' as their metadata.

Try the custom 'todos' feature by running the newly-added bit todos COMPONENT_NAME command in your terminal, or by exploring the newly-added 'To-dos' tab, in the UI. Make sure to restart your UI server, if it is already running.