-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
80 lines (76 loc) · 2.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
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 resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import analyze from "rollup-plugin-analyzer";
import externals from "rollup-plugin-node-externals";
import babel from "@rollup/plugin-babel";
import del from "rollup-plugin-delete";
import terser from '@rollup/plugin-terser';
const packageJson = require("./package.json");
const dateTime = new Date().toISOString();
const banner = `/**
* @preserve
* ${packageJson.name} v${packageJson.version}
* Last build: ${dateTime}
* ${packageJson.description}
* ${packageJson.homepage}
* (c) ${new Date().getFullYear()} ${packageJson.author.name} <${packageJson.author.email}>
* @license ${packageJson.license}
*/`
const onwarn = (warning) => {
// Skip circular dependency warnings
if (warning.code === "CIRCULAR_DEPENDENCY") {
return;
}
console.warn(`(!) ${warning.message}`)
}
export default {
input: "src/index.ts",
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
banner,
},
{
file: packageJson.module,
format: "esm",
sourcemap: true,
banner,
},
],
onwarn,
plugins: [
del({ targets: "build/*" }),
// devDependenciesnd and peerDependencies wont be included in the bundle
// if you want to also exculde dependencies, change deps to true
externals({ deps: true, devDeps: true, peerDeps: true }),
resolve(),
commonjs(),
typescript({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
exclude: ["**/__tests__", "**/*.test.tsx", "**/*.stories.tsx"]
}
}),
babel({
babelHelpers: "runtime",
exclude: "**/node_modules/**",
extensions: [".js", ".jsx", ".ts", ".tsx"],
}),
terser({
format: {
comments: (node, comment) => {
const text = comment.value;
const type = comment.type;
if (type == "comment2") {
// multiline comment
return /@preserve|@license|@cc_on/i.test(text);
}
},
},
}),
analyze(),
],
};