Any build task may generate artifacts. These artifacts can be persisted during the build process, as part of the component version data.
For example, the jest tester aspect generates a junit.xml
file with all test results.
To list a component's artifacts, use the bit artifact
command and provide the component's ID or full name:
bit artifacts ui/heading
You can show or fetch any of the artifacts:
bit artifact ui/heading --aspect teambit.pkg/pkg # fetch all artifacts generated by a specific aspect bit artifact ui/heading --task GeneratePreview # fetch all artifacts generated by a specific task bit artifact ui/heading --files "*heading*" # fetch all artifacts with a file name (from a pattern)
Use the --out-dir
option to extract artifacts from the component objects to a directory inside your workspace directory:
bit artifacts ui/heading --out-dir my-artifacts-directory
You can use artifacts in your Bit app deployment by accessing the context object as in the example below.
import type { AppDeployContext } from '@teambit/application'; import { exec } from 'node:child_process' import { join } from 'path'; export function deploy(context: AppDeployContext) { const appDir = context.capsule.path; const artifacts = context.artifacts; // echos all app artifacts and their locations. console.log(artifacts); await exec(`deploy ${artifactDirectory}`, { cwd: appDir }); };
You can use the artifacts command to write artifacts to the disk from your bash scripts:
bit artifacts my-org.my-scope/apps/my-app --task build_application --out-dir build
The artifacts are now available in the new build directory, at the root of your project.