-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
78 lines (75 loc) · 1.74 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
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import dts from 'rollup-plugin-dts';
import eslint from '@rollup/plugin-eslint';
import terser from '@rollup/plugin-terser';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const extensions = ['.js', '.ts'];
export default [
{
input: './src/browser.ts',
output: {
file: './dist/browser.js',
format: 'es',
},
plugins: [
alias({
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}),
resolve({ browser: true, extensions }),
commonjs(),
eslint(),
typescript(),
terser(),
],
},
{
input: './src/node.ts',
output: {
file: './dist/node.cjs',
format: 'cjs',
banner: '#!/usr/bin/env node',
},
plugins: [
alias({
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}),
resolve({ browser: false, extensions }),
commonjs(),
eslint(),
typescript(),
terser(),
],
},
{
input: './src/browser.ts',
output: [{
file: './dist/browser.d.ts',
format: 'es',
}],
plugins: [
alias({
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}),
dts(),
],
},
{
input: './src/node.ts',
output: [{
file: './dist/node.d.cts',
format: 'cjs',
}],
plugins: [
alias({
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}),
dts(),
],
},
]