-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
75 lines (60 loc) · 1.23 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
import typescript from '@rollup/plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
import { uglify } from "rollup-plugin-uglify";
const mini = process.env.MINI === '1';
const watch = process.env.WATCH === '1';
const target = process.env.TARGET || 'script';
const allTargets = target === 'all';
function optional(cond, obj) {
if (cond) {
return [obj];
}
return [];
}
function createConfig() {
let plugins = [
resolve(),
typescript(),
];
if (mini) {
plugins.push(uglify({
compress: {
passes: 3,
},
output: {
max_line_len: 128,
},
}));
}
return {
input: 'script.ts',
context: 'this',
watch: {
exclude: 'node_modules/**',
clearScreen: false,
},
plugins,
};
}
export default [
...optional(allTargets || target === 'script', {
...createConfig(),
input: 'script.ts',
output: {
file: 'dist/script.js',
format: 'iife',
compact: false,
strict: false,
},
}),
...optional(allTargets || target === '3d' , {
...createConfig(),
input: 'mcgl9/3d-export.js',
output: {
file: 'dist/3d.js',
format: 'iife',
compact: false,
strict: false,
},
}),
];