-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
98 lines (84 loc) · 2.51 KB
/
rollup.config.js
File metadata and controls
98 lines (84 loc) · 2.51 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @description Onsight Engine
* @about Easy to use 2D / 3D JavaScript game engine.
* @author Stephens Nunnally <@stevinz>
* @license MIT - Copyright (c) 2021 Stephens Nunnally
* @source https://github.com/scidian/onsight
*/
import { VERSION } from './src/constants.js'; // Pull in version
import { terser } from 'rollup-plugin-terser'; // Remove comments, minify
import { visualizer } from 'rollup-plugin-visualizer'; // Visualize
import cleanup from 'rollup-plugin-cleanup'; // Remove comments, supports sourcemap
// import obfuscator from 'rollup-plugin-obfuscator'; // Obfuscate
function header() {
return {
renderChunk(code) {
return `/**
* @description Onsight Engine
* @about Easy to use 2D / 3D JavaScript game engine.
* @author Stephens Nunnally <@stevinz>
* @version v${VERSION}
* @license MIT - Copyright (c) 2021 Stephens Nunnally
* @source https://github.com/scidian/onsight
*/
${code}`;
}
};
}
const builds = [
{ // Standard Build
input: './src/Onsight.js',
treeshake: false,
external: p => /^three/.test(p) || /^rapier/.test(p),
plugins: [
cleanup({
comments: "none",
extensions: [ "js", "ts" ],
sourcemap: false,
}),
header(),
],
output: [{
format: 'esm',
file: './build/onsight.module.js',
sourcemap: false,
}],
},
{ // Minified
input: './src/Onsight.js',
treeshake: false,
external: p => /^three/.test(p) || /^rapier/.test(p),
plugins: [
header(),
visualizer(),
],
output: [{
format: 'esm',
file: './build/onsight.min.js',
sourcemap: false,
plugins: [
terser({ format: { comments: false } }),
],
}],
},
/**
{ // Obfuscated
input: './src/Onsight.js',
treeshake: false,
external: p => /^three/.test(p) || /^rapier/.test(p),
plugins: [
obfuscator({ fileOptions: {}, globalOptions: {} }),
header(),
],
output: [{
format: 'esm',
file: './build/onsight.compile.js',
sourcemap: false,
plugins: [
terser({ format: { comments: false } }),
],
}],
},
**/
];
export default builds;