-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
50 lines (44 loc) · 1.08 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
import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve"
import typescript from "rollup-plugin-typescript2"
import { terser } from "rollup-plugin-terser"
import pkg from "./package.json"
const format = process.env.MODULE_FORMAT || "cjs"
const filename = process.env.MODULE_FILENAME
const isUMD = (format === "umd")
const file = "./dist/" + filename + ".js"
const output = {
name: pkg.name.replace("-", "_"),
file,
format,
sourcemap: false,
exports: "named"
}
const plugins = [
typescript({
tsconfigOverride: {
compilerOptions: {
module: "ES2015"
}
}
})
]
if (isUMD) {
plugins.push(resolve())
plugins.push(terser())
plugins.push(commonjs({
sourceMap: false
}))
}
export default {
input: `src/${filename}.ts`,
output,
plugins,
onwarn
}
function onwarn(message) {
const suppressed = ["UNRESOLVED_IMPORT", "THIS_IS_UNDEFINED"]
if (!suppressed.find((code) => message.code === code)) {
return console.warn(message.message)
}
}