-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
83 lines (76 loc) · 1.75 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
76
77
78
79
80
81
82
83
import typescript from '@rollup/plugin-typescript';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'
import htmlTemplate from 'rollup-plugin-generate-html-template';
import { env } from 'process';
const lib_cfg = {
input: 'src/index.ts',
external: ['three'],
output: [
{
name: 'MeshHalfEdgeLib',
format: 'umd',
file: 'build/index.umd.js',
sourcemap: true,
globals: {
'three':'three'
}
},
{
format: 'esm',
file: 'build/index.esm.js',
sourcemap: true,
}
],
plugins: [
typescript({
tsconfig: './tsconfig.json',
compilerOptions: {
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"declarationDir": "types",
},
exclude: ["examples/*", "node_modules"],
noEmitOnError: !env.ROLLUP_WATCH,
})
]
};
const examples = ['ExtractContours', 'HalfedgeDSVisualisation'];
const examples_cfg = []
for (const example of examples) {
examples_cfg.push(
{
input: `examples/${example}.ts`,
output: {
file: `build-examples/${example}.js`,
sourcemap: true,
},
plugins: [
nodeResolve({
browser: true,
}),
commonjs(),
typescript({
compilerOptions: {
"sourceMap": true,
},
tsconfig: './tsconfig.json',
noEmitOnError: !env.ROLLUP_WATCH,
}),
htmlTemplate({
template: `examples/${example}.html`,
target: `${example}.html`,
attrs: ['type="module"']
}),
]
}
);
}
let exported;
if (env.examples) {
exported = examples_cfg;
} else {
exported = lib_cfg;
}
export default exported;