This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
64 lines (56 loc) · 1.62 KB
/
rollup.config.ts
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
import { resolve } from "path"
import ts from "@wessberg/rollup-plugin-ts"
import commonjs from "@rollup/plugin-commonjs"
import nodeResolve from "@rollup/plugin-node-resolve"
import filesize from "rollup-plugin-filesize"
import { terser } from "rollup-plugin-terser"
const packageRoot = process.cwd()
const dev = Boolean(process.env.ROLLUP_WATCH)
const inputFile = resolve(packageRoot, "src/index.ts")
const _package = require(resolve(packageRoot, "package.json"))
const packageName = String(_package.name)
const commonPlugins = [nodeResolve(), commonjs()]
export default [
{
input: inputFile,
output: [
{
file: _package.main,
format: "cjs",
sourcemap: true
},
{
file: _package.browser,
sourcemap: true,
format: "umd",
name: packageName[0].toUpperCase() + packageName.substr(1)
}
],
plugins: [...commonPlugins, ts(), !dev && terser()]
},
{
input: inputFile,
output: [
{
file: _package.module,
format: "esm",
sourcemap: true
}
],
plugins: [
...commonPlugins,
ts({
tsconfig: {
declaration: true,
...require(resolve(__dirname, "tsconfig.json"))[
"compilerOptions"
]
}
}),
!dev && terser(),
filesize({
showBrotliSize: true
})
]
}
]