-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
executable file
·72 lines (65 loc) · 2.38 KB
/
rollup.config.js
File metadata and controls
executable file
·72 lines (65 loc) · 2.38 KB
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
import {terser} from 'rollup-plugin-terser';
import resolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import commonjs from 'rollup-plugin-commonjs';
import babel from "rollup-plugin-babel";
import json from 'rollup-plugin-json';
import replace from 'rollup-plugin-replace';
// `npm run build` -> `production` is true
// `npm run dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;
let apiHost = process.env.SDK_API_HOST || 'http://localhost:3000/collect';
let version = process.env.SDK_VERSION || require('./package.json').version || 'beta';
// remove the # used to escape the
apiHost = apiHost.replace(/#/g, ':');
console.log("SDK for " + apiHost);
/**
*
*/
export default {
input: 'web-sdk-cli/src/main.js',
format: 'iife',
output: {
file: production ? 'public/assets/sdk.js' : 'public/assets/sdk-test.js',
format: 'iife', // immediately-invoked function expression — suitable for <script> tags
sourcemap: !production,
},
plugins: [
replace({
values: {
'SDK_API_HOST': apiHost,
'SDK_VERSION': version
},
}),
resolve({jsnext: true, preferBuiltins: true, browser: true, main: true}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
browser: true,
preferBuiltins: false,
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false // Default: true
// explicitly specify unresolvable named exports
// (see below for more details)
// namedExports: { './module.js': ['foo', 'bar' ] } // Default: undefined
}),
json(),
babel({
runtimeHelpers: true,
exclude: "node_modules/**",
plugins: [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}),
globals,
production && terser() // minify, but only in production
]
};