-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.api.js
85 lines (79 loc) · 2 KB
/
rollup.api.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
84
85
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import svelte from 'rollup-plugin-svelte';
const mode = process.env.NODE_ENV;
const dev = mode === 'development';
const baseConfig = {
plugins: [
replace({
preventAssignment: true,
'import.meta.env.VITE_SERVERTYPE': JSON.stringify(process.env.VITE_SERVERTYPE),
'import.meta.env.DEV': dev.toString(),
}),
alias({
entries: {
// '$lib': 'src/lib',
'$app/environment': 'src/api/env.js',
//'$app': '.svelte-kit/build/runtime/app',
},
}),
svelte({
compilerOptions: {
// enable run-time checks when not in production
dev,
accessors:true,
// we'll extract any component CSS out into
// a separate file - better for performance
// css: css => { css.write('animation-widget.css'); }
},
emitCss: false
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
!dev && terser(),
],
watch: {
clearScreen: false
}
};
const configs = [
{
input: './src/lib/CausalDiagramWidget.svelte',
name: 'CausalDiagramWidget',
file: 'static/api/causal-diagram-widget-standalone.mjs',
},
{
input: './src/lib/AnimationWidget.svelte',
name: 'AnimationWidget',
file: 'static/api/animation-widget-standalone.mjs',
},
].map(config => {
return Object.assign({}, baseConfig, {
input: config.input,
output: [
{
sourcemap: true,
format: 'esm',
file: config.file,
inlineDynamicImports: true,
},
{
sourcemap: true,
format: 'iife',
name: config.name,
file: config.file.replace(/\.mjs$/, '.js'),
inlineDynamicImports: true,
}
],
});
});
export default configs;