-
Notifications
You must be signed in to change notification settings - Fork 14
/
rollup.config.mjs
66 lines (59 loc) · 2.24 KB
/
rollup.config.mjs
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
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import {fileURLToPath} from 'url';
// Temporary fix for: https://github.com/rollup/plugins/pull/1367
const __filename = fileURLToPath(import.meta.url);
global['__filename'] = __filename;
export default args => {
if (args['config-cdn-url'] === undefined) {
throw new Error('The argument "config-cdn-url" is missing.');
}
if (args['config-playground-origin'] === undefined) {
throw new Error('The argument "config-playground-origin" is missing.');
}
if (args['config-playground-connect-url'] === undefined) {
throw new Error('The argument "config-playground-connect-url" is missing.');
}
if (args['config-preview-widget-origin'] === undefined) {
throw new Error('The argument "config-preview-widget-origin" is missing.');
}
if (args['config-preview-widget-url'] === undefined) {
throw new Error('The argument "config-preview-widget-url" is missing.');
}
return [
{
input: 'src/index.ts',
output: {
file: 'build/plug.min.js',
name: 'croct',
format: 'iife',
},
context: 'this',
treeshake: {
propertyReadSideEffects: false,
},
plugins: [
resolve(),
commonjs(),
typescript({module: 'esnext'}),
replace({
preventAssignment: true,
delimiters: ['<@', '@>'],
cdnUrl: args['config-cdn-url'],
playgroundOrigin: args['config-playground-origin'],
playgroundConnectUrl: args['config-playground-connect-url'],
previewWidgetOrigin: args['config-preview-widget-origin'],
previewWidgetUrl: args['config-preview-widget-url'],
}),
terser({
format: {
comments: false,
},
}),
],
},
];
};