Skip to content

Commit 37c308f

Browse files
committed
move license plugin to shared config
1 parent 10a021e commit 37c308f

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

packages/browser/rollup.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { terser } from 'rollup-plugin-terser';
22
import typescript from 'rollup-plugin-typescript2';
3-
import license from 'rollup-plugin-license';
43
import resolve from '@rollup/plugin-node-resolve';
54
import replace from '@rollup/plugin-replace';
65

7-
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
6+
import { makeLicensePlugin } from '../../rollup.config';
7+
8+
const licensePlugin = makeLicensePlugin();
89

910
const terserInstance = terser({
1011
compress: {
@@ -81,13 +82,7 @@ const bundleConfig = {
8182
esModule: false,
8283
},
8384
context: 'window',
84-
plugins: [
85-
...plugins,
86-
license({
87-
sourcemap: true,
88-
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
89-
}),
90-
],
85+
plugins: [...plugins, licensePlugin],
9186
treeshake: 'smallest',
9287
};
9388

packages/tracing/rollup.config.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import typescript from 'rollup-plugin-typescript2';
2-
import license from 'rollup-plugin-license';
32
import resolve from '@rollup/plugin-node-resolve';
43
import replace from '@rollup/plugin-replace';
54

6-
import { terserPlugin } from '../../rollup.config';
5+
import { makeLicensePlugin, terserPlugin } from '../../rollup.config';
76

8-
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
7+
const licensePlugin = makeLicensePlugin('@sentry/tracing & @sentry/browser');
98

109
const paths = {
1110
'@sentry/utils': ['../utils/src'],
@@ -54,13 +53,7 @@ const bundleConfig = {
5453
esModule: false,
5554
},
5655
context: 'window',
57-
plugins: [
58-
...plugins,
59-
license({
60-
sourcemap: true,
61-
banner: `/*! @sentry/tracing & @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
62-
}),
63-
],
56+
plugins: [...plugins, licensePlugin],
6457
treeshake: 'smallest',
6558
};
6659

packages/vue/rollup.config.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import typescript from 'rollup-plugin-typescript2';
2-
import license from 'rollup-plugin-license';
32
import resolve from '@rollup/plugin-node-resolve';
43
import replace from '@rollup/plugin-replace';
54

6-
import { terserPlugin } from '../../rollup.config';
5+
import { makeLicensePlugin, terserPlugin } from '../../rollup.config';
76

8-
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
7+
const licensePlugin = makeLicensePlugin();
98

109
const paths = {
1110
'@sentry/utils': ['../utils/src'],
@@ -54,13 +53,7 @@ const bundleConfig = {
5453
esModule: false,
5554
},
5655
context: 'window',
57-
plugins: [
58-
...plugins,
59-
license({
60-
sourcemap: true,
61-
banner: `/*! @sentry/vue <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
62-
}),
63-
],
56+
plugins: [...plugins, licensePlugin],
6457
treeshake: 'smallest',
6558
};
6659

rollup.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,27 @@
22
* Shared config used by individual packages' Rollup configs
33
*/
44

5+
import license from 'rollup-plugin-license';
56
import { terser } from 'rollup-plugin-terser';
67

8+
9+
/**
10+
* Create a plugin to add an identification banner to the top of stand-alone bundles.
11+
*
12+
* @param title The title to use for the SDK, if not the package name
13+
* @returns An instance of the `rollup-plugin-license` plugin
14+
*/
15+
export function makeLicensePlugin(title) {
16+
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
17+
18+
return license({
19+
banner: {
20+
content: `/*! <%= data.title || pkg.name %> <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
21+
data: { title },
22+
},
23+
});
24+
}
25+
726
export const terserPlugin = terser({
827
mangle: {
928
// captureExceptions and captureMessage are public API methods and they don't need to be listed here

0 commit comments

Comments
 (0)