-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
76 lines (73 loc) · 2.11 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {execSync} from 'child_process';
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import native from 'rollup-plugin-natives';
import copy from 'rollup-plugin-copy';
import builtins from 'builtin-modules';
import commonjs from '@rollup/plugin-commonjs';
import replace from 'rollup-plugin-replace';
import json from '@rollup/plugin-json';
const shared = [
typescript({
tsconfig: false,
allowSyntheticDefaultImports: true,
resolveJsonModule: true,
target: 'es2022',
include: ['src/back/*.ts', 'src/lib/*.ts']
}),
resolve({
preferBuiltins: true
}),
replace({
"require('readable-stream/transform')": "require('stream').Transform",
'require("readable-stream/transform")': 'require("stream").Transform',
'readable-stream': 'stream',
'global.__BUILD__': JSON.stringify(execSync('echo -n `git rev-parse --short HEAD` `date +%Y-%m-%d`').toString())
}),
commonjs({
include: ['node_modules/**', 'src/**']
}),
json()
];
const gdal = [
native({
copyTo: 'build/back/lib',
destDir: './lib'
}),
copy({
targets: [
{
src: 'node_modules/gdal-async/deps/libgdal/gdal/data',
dest: 'build/deps/libgdal/gdal'
},
{
src: 'node_modules/gdal-async/deps/libproj/proj/data',
dest: 'build/deps/libproj/proj'
}
]
})
];
export default [
...['dbserver', 'wind'].map((f) => ({
input: `src/back/${f}.ts`,
output: {
file: `build/back/${f}.js`,
format: 'cjs',
exports: 'auto',
compact: true
},
external: builtins,
plugins: [...gdal, ...shared]
})),
...['classify', 'import', 'launches'].map((f) => ({
input: `src/back/${f}.ts`,
output: {
file: `build/back/${f}.js`,
format: 'cjs',
exports: 'auto',
compact: true
},
external: builtins,
plugins: shared
}))
];