-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
44 lines (42 loc) · 1.02 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import { execSync } from 'child_process';
function getVersion() {
try {
const tag = execSync('git describe --tags --abbrev=0').toString().trim();
if (tag.startsWith('v')) {
return tag.substring(1);
}
return tag;
} catch (e) {
try {
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
return `0.0.0-${branch}`;
} catch (e) {
return '0.0.0-dev';
}
}
}
export default {
input: 'src/sugartv-card.js',
output: {
file: 'dist/sugartv-card.js',
format: 'es',
banner: `/* SugarTV Card version ${getVersion()} */`,
},
plugins: [
replace({
'process.env.VERSION': JSON.stringify(getVersion()),
preventAssignment: true
}),
resolve(),
json(),
terser({
format: {
comments: /SugarTV Card version/,
},
}),
],
};