Step 1. Install
npm install --save-dev @relative-ci/rollup-pluginyarn add --dev @relative-ci/rollup-pluginpnpm add -D @relative-ci/rollup-pluginStep 2. Configure
Rollup
Add @relative-ci/rollup-plugin to your rollup config:
import relativeCiAgent from '@relative-ci/rollup-plugin';
export default { // ... your rollup config plugins: [ // ... other plugins relativeCiAgent() ]};import relativeCiAgent from '@relative-ci/rollup-plugin';
export default { // ... your rollup config plugins: [ // ... other plugins relativeCiAgent() ]};const relativeCiAgent = require('@relative-ci/rollup-plugin');
module.exports = { // ... your rollup config plugins: [ // ... other plugins relativeCiAgent() ]};Plugin options
enabled- send bundle stats and build information to RelativeCI (default to env-ciisCi)failOnError- fail build when encountering errors (default:false)includeCommitMessage( defaulttrue) - get current commit message (CI env data orgit log -1 --pretty=%B) and send it to RelativeCI as part of the build informationcompress(defaultfalse) - enable ingest payload compressionpayloadFilepath- save agent payload to disk for debuggingstats- rollup-plugin-stats options:excludeAssets- exclude matching assets:string | RegExp | ((filepath: string) => boolean) | Array<string | RegExp | ((filepath: string) => boolean)>excludeModules- exclude matching modules:string | RegExp | ((filepath: string) => boolean) | Array<string | RegExp | ((filepath: string) => boolean)>
Step 3. Configure Continuous Integration(CI) service
The plugin sends the build information and the bundle stats to RelativeCI ingestion service when enabled option is true. When running on supported CI services the option is set by default to true.
If you run multiple build tasks as part of your CI flow, consider to enable the plugin only for one task or setup one RelativeCI project for each build task.
Add environment variables
Follow the CI service guide to add the corresponding secrets and environment variables:
RELATIVE_CI_KEY - required
Your project RelativeCI API key. To view the corresponding key for your project, navigate to https://app.relative-ci.com and go to the project Settings -> API Keys page.
More resources:
Monorepo
If you are using a monorepo setup and need to send the build information and the stats for multiple projects, use different API keys for each project.
GitHub Action example
# ... - name: Project A - build run: cd project-a && npm build env: RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY_PROJECT_A }}
- name: Project B - build run: cd project-b && npm build env: RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY_PROJECT_B }}Npm workspaces example
Pass projects RelativeCI key environment variables to the npm workspaces build task:
# ... - run: npm run build --workspaces env: APP_1_RELATIVE_CI_KEY: ${{ secrets.APP_1_RELATIVE_CI_KEY }} APP_2_RELATIVE_CI_KEY: ${{ secrets.APP_2_RELATIVE_CI_KEY }}Add project specific RelativeCI key environment variable to the project's build script:
{ "name": "app-1", "scripts": { "build": "RELATIVE_CI_KEY=$APP_1_RELATIVE_CI_KEY npm run build" }}{ "name": "app-2", "scripts": { "build": "RELATIVE_CI_KEY=$APP_2_RELATIVE_CI_KEY npm run build" }}Lerna example
Pass projects RelativeCI key environment variables to the lerna build task:
# ... - run: npx lerna run build env: APP_1_RELATIVE_CI_KEY: ${{ secrets.APP_1_RELATIVE_CI_KEY }} APP_2_RELATIVE_CI_KEY: ${{ secrets.APP_2_RELATIVE_CI_KEY }}Add project specific RelativeCI key environment variable to the project's build script:
{ "name": "app-1", "scripts": { "build": "RELATIVE_CI_KEY=$APP_1_RELATIVE_CI_KEY npm run build" }}{ "name": "app-2", "scripts": { "build": "RELATIVE_CI_KEY=$APP_2_RELATIVE_CI_KEY npm run build" }}