-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrollup.config.js
105 lines (103 loc) · 2.62 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
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import rollupTypescript from '@rollup/plugin-typescript';
import { join } from 'path';
import dts from 'rollup-plugin-dts';
const external = []; //Object.keys(p.dependencies);
module.exports = [
// build node
{
input: 'src/node.ts',
output: {
file: 'package/node.js',
sourcemap: true,
format: 'cjs',
},
external,
plugins: [
rollupTypescript(require('./tsconfig.json').compilerOptions),
commonjs({ extensions: ['.js', '.ts'] }),
nodeResolve(),
],
},
// build node.d.ts
{
input: 'src/node.ts',
output: {
file: 'package/node.d.ts',
format: 'esm',
},
external,
plugins: [
dts.default({
tsconfig: 'tsconfig.json',
compilerOptions: { removeComments: false, declaration: true },
}),
],
},
// build web
{
input: 'src/web.ts',
output: {
name: 'web.js',
file: 'package/web.js',
sourcemap: true,
format: 'umd',
globals: { axios: 'axios', nanoid: 'nanoid' },
},
external,
plugins: [
rollupTypescript({
exclude: ['src/node.ts'],
tsconfig: join(__dirname, 'tsconfig.web.json'),
}),
],
},
// build web.d.ts
{
input: 'src/web.ts',
output: {
file: 'package/web.d.ts',
format: 'esm',
},
external,
plugins: [
dts.default({
tsconfig: 'tsconfig.json',
compilerOptions: { removeComments: false, declaration: true },
}),
],
},
// build es module
{
input: 'src/es.ts',
output: {
name: 'es.js',
file: 'package/es.js',
sourcemap: true,
format: 'es',
},
external,
plugins: [
rollupTypescript({
exclude: ['src/node.ts'],
tsconfig: join(__dirname, 'tsconfig.json'),
}),
],
},
// build es.d.ts
{
input: 'src/es.ts',
output: {
file: 'package/es.d.ts',
format: 'esm',
},
external,
plugins: [
dts.default({
tsconfig: 'tsconfig.json',
compilerOptions: { removeComments: false, declaration: true },
}),
],
},
];