Skip to content

Commit 6e5ab5c

Browse files
committed
update rollup build
1 parent 0a45d29 commit 6e5ab5c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/experiment-tag/rollup.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { execSync } from 'child_process';
12
import { join, resolve as pathResolve } from 'path';
23

34
import tsConfig from '@amplitude/experiment-js-client/tsconfig.json';
@@ -13,6 +14,15 @@ import license from 'rollup-plugin-license';
1314

1415
import * as packageJson from './package.json';
1516

17+
let branchName = '';
18+
try {
19+
const fullBranch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();
20+
const cleanBranch = fullBranch.replace(/^web\//, '');
21+
branchName = cleanBranch !== 'main' ? cleanBranch : '';
22+
} catch (error) {
23+
console.warn('Unable to get git branch name:', error.message);
24+
}
25+
1626
const getCommonBrowserConfig = (target) => ({
1727
input: 'src/index.ts',
1828
treeshake: {
@@ -54,7 +64,7 @@ const getOutputConfig = (outputOptions) => ({
5464
output: {
5565
dir: 'dist',
5666
name: 'WebExperiment',
57-
banner: `/* ${packageJson.name} v${packageJson.version} - For license info see https://unpkg.com/@amplitude/experiment-tag@${packageJson.version}/files/LICENSE */`,
67+
banner: `/* ${packageJson.name} v${packageJson.version}${branchName ? ` (${branchName})` : ''} - For license info see https://unpkg.com/@amplitude/experiment-tag@${packageJson.version}/files/LICENSE */`,
5868
...outputOptions,
5969
},
6070
});

0 commit comments

Comments
 (0)