Setting Envs

A development environment ('env') is a collection of tools and configurations a component uses for its development, build, and delivery of components.

An env is a single component. It can be shared between teammates working on the same project to ensure all components use the same tools and adhere to the same standards, even when they are developed and delivered independently.

List component' envs

Bit offers various envs that you can use as the basis for your own envs. Find the 'Set up an env' page under the framework you're using, to learn more about creating an env for components of that framework.

Run the following to list the components maintained by your workspace, and their envs:

$bit
Copiedcopy

The output lists components and envs maintained by your workspace.
Explore this output by clicking on the components listed!

┌───────────────────────────────────────┬─────────────────────────────┐
component │ env
├───────────────────────────────────────┼─────────────────────────────┤
my-org.dev/my-react-env │ teambit.envs/env
├───────────────────────────────────────┼─────────────────────────────┤
my-org.tasks-scope/apps/to-do │ my-org.dev/my-react-env
├───────────────────────────────────────┼─────────────────────────────┤
my-org.network/check-ok-status │ teambit.harmony/node
└───────────────────────────────────────┴─────────────────────────────┘

Configure components with envs

When you create a component, it is already configured with a default env. This env is set by the same template (generator) that was responsible for creating its source files. For example:

$bit
Copiedcopy

The output confirms that a new component was created, and that its env is 'react-env':

my-org.tasks-scope/apps/to-do location: tasks-scope/apps/button env: my-org.react/react-env (set by template)

To override the default env set by the component template use the --env option. For example:

$bit
Copiedcopy

Change a component's env

You can also set a component with a different env, after it's been created or even snapped. For example, the following sets the component with 'my-react' env:

$bit
Copiedcopy
See command synopsis

The output confirms that the new component is set with the custom env:

added my-org.my-scope/envs/my-react env to the following component(s): my-org.tasks-scope/apps/to-do

Replace one env with another

To select all components that use a specific env, and replace their env with another env, run the following:

$bit
Copiedcopy
See command synopsis

This process is often useful when you want to replace an env with a newer version of it, or when you want to replace an env that you have no permissions to modify, with your own custom env.

Run env services

Components maintained by the same workspace often use different dev tools and configurations, each component, according to the env it uses. Env services simplify component development by operating these tools via a standardized interface (API, CLI, and UI).

For example, the following runs the compiler service on all components in the workspace, regardless of the specific compiler set by their envs (Typescript, Babel, etc.):

$bit
Copiedcopy

The output lists all components affected by the compilation. Notice how the env (a component itself) and the component that uses it, were both compiled, even though each of them uses a different env (and possibly, a different compiler):

STATUS COMPONENT ID
SUCCESS envs/my-react
SUCCESS apps/to-do

Explore the different services in the the list below:

Test


Compile


Lint


Format


Build pipelines


Preview and Docs


Component generators


Workspace starters