-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
70 lines (65 loc) · 1.55 KB
/
rollup.config.mjs
File metadata and controls
70 lines (65 loc) · 1.55 KB
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
import {readFileSync} from 'node:fs';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import dts from 'rollup-plugin-dts';
const {version: VERSION} = JSON.parse(readFileSync('./package.json', 'utf-8'));
const external = ['react', 'react-dom', 'react/jsx-runtime', 'fast-deep-equal'];
const plugins = [
resolve(),
commonjs(),
typescript({
tsconfig: './tsconfig.build.json',
declaration: false,
declarationDir: undefined
}),
replace({
preventAssignment: true,
include: ['src/version.ts'],
values: {
__PACKAGE_VERSION__: VERSION
}
})
];
const createConfig = (input, outputBase) => [
// ESM and UMD builds
{
input,
output: [
{
file: `${outputBase}.modern.mjs`,
format: 'es',
sourcemap: true
},
{
file: `${outputBase}.umd.js`,
format: 'umd',
name: 'ReactGoogleMaps',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'React',
'fast-deep-equal': 'fastDeepEqual'
},
sourcemap: true
}
],
external,
plugins
},
// TypeScript declarations
{
input,
output: {
file: `${outputBase}.d.ts`,
format: 'es'
},
external,
plugins: [dts()]
}
];
export default [
...createConfig('./src/index.ts', './dist/index'),
...createConfig('./src/server/index.ts', './dist/server/index')
];