-
Notifications
You must be signed in to change notification settings - Fork 256
/
rollup.config.js
68 lines (67 loc) · 1.89 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
/* eslint-disable no-undef */
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { uglify } from 'rollup-plugin-uglify';
import dts from 'rollup-plugin-dts';
import fs from 'fs';
import path from 'path';
const packagesDir = path.resolve(__dirname, 'packages');
const packageFiles = fs.readdirSync(packagesDir);
function output(path) {
return [
{
input: [`./packages/${path}/src/index.ts`],
output: [
{
file: `./packages/${path}/dist/index.cjs.js`,
format: 'cjs',
sourcemap: true,
},
{
file: `./packages/${path}/dist/index.esm.js`,
format: 'esm',
sourcemap: true,
},
{
file: `./packages/${path}/dist/index.js`,
format: 'umd',
name: 'web-see',
sourcemap: true,
},
{
file: `./packages/${path}/dist/index.min.js`,
format: 'umd',
name: 'web-see',
sourcemap: true,
plugins: [uglify()],
},
],
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'ESNext',
},
},
useTsconfigDeclarationDir: true,
}),
resolve(),
commonjs(),
json(),
],
},
{
input: `./packages/${path}/src/index.ts`,
output: [
{ file: `./packages/${path}/dist/index.cjs.d.ts`, format: 'cjs' },
{ file: `./packages/${path}/dist/index.esm.d.ts`, format: 'esm' },
{ file: `./packages/${path}/dist/index.d.ts`, format: 'umd' },
{ file: `./packages/${path}/dist/index.min.d.ts`, format: 'umd' },
],
plugins: [dts()],
},
];
}
export default [...packageFiles.map(path => output(path)).flat()];