-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
60 lines (57 loc) · 1.39 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
import path from 'node:path';
import typescript from '@rollup/plugin-typescript';
import alias from '@rollup/plugin-alias';
import terser from '@rollup/plugin-terser';
import replace from '@rollup/plugin-replace';
import wgsl from './src/wgsl_loader.mjs';
import html from './src/html_loader.mjs';
const entries = ['hello', 'landscape', 'sunset'];
const projectRootDir = path.dirname(import.meta.url.replace("file://", ""));
const enginePath = path.resolve(projectRootDir, './src/engine/');
const production = !process.env.ROLLUP_WATCH;
export default entries.map(entry => ({
input: `src/${entry}/index.ts`,
output: {
file: `public/${entry}.bundle.js`,
format: 'module',
sourcemap: !production,
},
watch: {
clearScreen: false,
},
plugins: [
wgsl({ stripWhitespace: production }),
html({ stripWhitespace: production }),
typescript({
tsconfig: 'tsconfig.json',
sourceMap: !production,
inlineSources: !production,
}),
alias({
entries: [
{
find: 'engine',
replacement: enginePath
}
]
}),
replace({
preventAssignment: true,
'PRODUCTION': JSON.stringify(production),
'DEBUG': JSON.stringify(!production),
}),
production && terser({
compress: {
drop_console: ['log', 'debug', 'info'],
ecma: 2020,
passes: 4
}
}),
],
onLog(level, log, handler) {
if (log.code === 'CIRCULAR_DEPENDENCY') {
return;
}
handler(level, log);
}
}));