-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathrollup.config.js
83 lines (78 loc) · 2.21 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import commonjs from 'rollup-plugin-commonjs';
import license from 'rollup-plugin-license';
import resolve from 'rollup-plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import { generate_cfg, paths } from '../../resources/rollup.base';
const commitHash = require('child_process')
.execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
.trim();
const terserInstance = terser({
mangle: {
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
// We need those full names to correctly detect our internal frames for stripping.
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
properties: {
regex: /^_[^_]/,
},
},
});
const plugins = [
typescript({
tsconfig: 'tsconfig.build.json',
tsconfigOverride: {
compilerOptions: {
declaration: false,
module: 'ES2015',
paths,
},
},
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
}),
resolve({
browser: true,
module: false,
modulesOnly: true,
}),
commonjs(),
];
const bundleConfig = {
input: 'src/index.ts',
output: {
format: 'iife',
name: 'Sentry',
sourcemap: true,
},
context: 'window',
plugins: [
...plugins,
license({
sourcemap: true,
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
}),
],
};
export default [
{
...bundleConfig,
output: {
...bundleConfig.output,
file: 'bundles/bundle.js',
},
},
{
...bundleConfig,
output: {
...bundleConfig.output,
file: 'bundles/bundle.min.js',
},
// Uglify has to be at the end of compilation, BUT before the license banner
plugins: bundleConfig.plugins
.slice(0, -1)
.concat(terserInstance)
.concat(bundleConfig.plugins.slice(-1)),
},
...generate_cfg('browser'),
];