This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
80 lines (76 loc) · 1.91 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
import babel from '@rollup/plugin-babel'
import cleanup from 'rollup-plugin-cleanup'
import commonjs from '@rollup/plugin-commonjs'
import del from 'rollup-plugin-delete'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import pkg from './package.json'
import replace from '@rollup/plugin-replace'
import strip from '@rollup/plugin-strip'
import ttypescript from 'ttypescript'
import typescript from 'rollup-plugin-typescript2'
import { license } from '../../license.ts'
const mode = {
PRODUCTION: 'production',
DEVELOPMENT: 'development'
}
const extensions = ['.js', '.ts']
const isProduction = process.env.NODE_ENV === mode.PRODUCTION
const includePattern = 'src/**/*'
const config = {
input: pkg.source,
output: [
{
file: pkg.main,
exports: 'named',
format: 'cjs',
banner: license
},
{
file: pkg.module,
exports: 'named',
format: 'es',
banner: license
}
],
plugins: [
del({
targets: 'dist/*',
runOnce: true
}),
peerDepsExternal({ includeDependencies: true }),
nodeResolve({ extensions }),
commonjs(),
replace(
{
'process.env.NODE_ENV': JSON.stringify(
isProduction ? mode.PRODUCTION : mode.DEVELOPMENT
),
preventAssignment: true
},
{
include: includePattern
}
),
json({ include: includePattern }),
typescript({
typescript: ttypescript,
tsconfigOverride: {
exclude: ['__tests__/**/*']
}
}),
babel({
extensions,
babelHelpers: 'runtime',
include: includePattern
}),
cleanup({
extensions: extensions.map((ext) => ext.trimStart('.')),
comments: 'none',
include: includePattern
}),
...(isProduction ? [strip({ include: includePattern })] : [])
]
}
export default config