This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrollup.config.js
109 lines (106 loc) · 2.01 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
103
104
105
106
107
108
109
import typescript from '@rollup/plugin-typescript';
import fs from 'fs';
import autoExternal from 'rollup-plugin-auto-external';
import define from 'rollup-plugin-define';
import del from 'rollup-plugin-delete';
import dts from 'rollup-plugin-dts';
import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
const packageJson = require('./package.json');
export default [
{
input: 'src/index.ts',
output: {
file: packageJson.main,
sourcemap: true,
format: 'cjs'
},
plugins: [
define({
replacements: {
BUILD_VERSION: JSON.stringify(require('./package.json').version)
}
}),
typescript({
tsconfig: './tsconfig.json'
}),
autoExternal(),
terser()
]
},
{
input: 'src/index.ts',
output: {
file: packageJson.module,
sourcemap: true,
format: 'esm'
},
plugins: [
define({
replacements: {
BUILD_VERSION: JSON.stringify(require('./package.json').version)
}
}),
typescript({
tsconfig: './tsconfig.json'
}),
autoExternal(),
terser()
]
},
{
input: 'src/index.ts',
external: ['react'],
inlineDynamicImports: true,
output: {
file: 'dist/index.umd.js',
format: 'umd',
sourcemap: true,
name: 'Descope',
globals: {
react: 'React'
}
},
plugins: [
define({
replacements: {
BUILD_VERSION: JSON.stringify(require('./package.json').version)
}
}),
typescript({
tsconfig: './tsconfig.json'
}),
commonjs(),
nodeResolve(),
terser()
]
},
{
input: './dist/src/index.d.ts',
output: [{ file: packageJson.types, format: 'esm' }],
plugins: [
dts(),
del({
hook: 'buildEnd',
targets: [
'./dist/test',
'./dist/src',
'./dist/cjs/!(index.cjs.*|package.json)'
]
}),
cjsPackage()
]
}
];
function cjsPackage() {
return {
name: 'cjsPackage',
buildEnd: () => {
fs.writeFileSync(
'./dist/cjs/package.json',
JSON.stringify({ type: 'commonjs' })
);
}
};
}