-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
48 lines (43 loc) · 1.43 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
import typescript from '@rollup/plugin-typescript';
import replace from '@rollup/plugin-replace';
import { readdirSync } from "fs";
import { parse } from "path";
const WIDGET_LOADER_BANNER = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: __iconColor__; icon-glyph: __iconGlyph__;
`;
import devConfig from './config.dev.json' assert { type: "json" };
import prodConfig from './config.prod.json' assert { type: "json" };
const dev = (process.env.NODE_ENV !== 'production');
const configValues = dev ? devConfig : prodConfig;
const widgetModuleFilenames = readdirSync("scripts/")
.filter(fileName => fileName.endsWith(".ts"));
function getBanner(fileName){
if (['IncidenceWidget.js.ts'].includes(fileName)){
// add header for RKI License
return WIDGET_LOADER_BANNER + '// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0';
}
else {
return WIDGET_LOADER_BANNER;
}
}
export default [
...(widgetModuleFilenames.map(fileName => (
{
input: `scripts/${fileName}`,
output: {
dir: './build',
format: 'es',
strict: false,
name: parse(fileName).name,
banner: getBanner(fileName),
},
plugins: [
typescript(),
replace({
preventAssignment: true,
values: configValues
}),
]
}))),
];