forked from pocketbase/js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
102 lines (94 loc) · 2.72 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import ts from 'rollup-plugin-ts';
import { terser } from 'rollup-plugin-terser';
const isProduction = !process.env.ROLLUP_WATCH;
function basePlugins() {
return [
ts(),
// minify if we're building for production
// (aka. npm run build instead of npm run dev)
isProduction && terser({
output: {
comments: false,
},
}),
]
}
export default [
// ES bundle (the PocketBase client as default export + additional helper classes).
{
input: 'src/index.ts',
output: [
{
file: 'dist/pocketbase.es.mjs',
format: 'es',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// ES bundle but with .js extension.
//
// This is needed mainly because of React Native not recognizing the mjs
// extension by default (see https://github.com/pocketbase/js-sdk/issues/47).
{
input: 'src/index.ts',
output: [
{
file: 'dist/pocketbase.es.js',
format: 'es',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// UMD bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.umd.js',
format: 'umd',
exports: 'default',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// CommonJS bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.cjs.js',
format: 'cjs',
exports: 'default',
sourcemap: isProduction,
}
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
// !!!
// @deprecated - kept only for backwards compatibility and will be removed in v1.0.0
// !!!
//
// Browser-friendly iife bundle (only the PocketBase client as default export).
{
input: 'src/Client.ts',
output: [
{
name: 'PocketBase',
file: 'dist/pocketbase.iife.js',
format: 'iife',
sourcemap: isProduction,
},
],
plugins: basePlugins(),
watch: { clearScreen: false },
},
];