-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
86 lines (80 loc) · 1.88 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
import external from 'rollup-plugin-peer-deps-external';
import ts from 'rollup-plugin-ts';
import { terser } from 'rollup-plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import filesize from 'rollup-plugin-filesize';
import pkg from './package.json';
import tsconfig from './tsconfig.json';
const production = !process.env.ROLLUP_WATCH;
const input = 'src/main.ts';
function resolveEntries() {
return Object.entries(
tsconfig.compilerOptions.paths
).map(([find, [replacement]]) => ({ find, replacement }));
}
console.log(input, pkg, tsconfig)
export default [
{
input,
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' },
],
plugins: [
external(),
ts(),
alias({
resolve: ['.ts', '.tsx'],
entries: resolveEntries(),
}),
commonjs({
include: ['node_modules/**'],
}),
production && filesize(),
],
},
{
input,
output: { file: pkg.browser, name: 'Loader', format: 'umd' },
plugins: [
external(),
ts(),
alias({
resolve: ['.ts', '.tsx'],
entries: resolveEntries(),
}),
resolve(),
commonjs({
include: ['node_modules/**'],
}),
terser(),
production && filesize(),
],
},
{
input: 'example/src/index.js',
output: {
name: 'howLongUntilLunch',
file: 'example/dist/index.js',
format: 'umd'
},
plugins: [
external(),
ts(),
alias({
resolve: ['.ts', '.tsx'],
entries: resolveEntries(),
}),
resolve(),
commonjs({
include: ['node_modules/**'],
}),
terser(),
production && filesize(),
//resolve(), // so Rollup can find `ms`
//commonjs() // so Rollup can convert `ms` to an ES module
]
},
];