-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
95 lines (90 loc) · 2.47 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
87
88
89
90
91
92
93
94
95
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import { visualizer } from "rollup-plugin-visualizer";
import replace from "@rollup/plugin-replace";
import pkg from "./package.json";
import imagemin from "imagemin";
const replacePlugin = replace({
preventAssignment: true,
values: {
PACKAGE_NAME: JSON.stringify(pkg.name),
PACKAGE_VERSION: JSON.stringify(pkg.version),
},
});
const typescriptPlugin = typescript({
target: "ES6",
module: "ES6",
removeComments: true,
});
const terserPlugin = terser({
format: {
preamble: `/*! ${require("./tasks/banner/banner.js")} */`,
comments: false,
},
});
const onwarn = (warning, rollupWarn) => {
if (warning.code !== "CIRCULAR_DEPENDENCY") {
rollupWarn(warning);
}
};
export default [
{
input: ["./src/builder/index.ts"],
output: [
{
file: "./builder/esm/index.mjs",
format: "esm",
exports: "named",
},
],
external: [
"@tripetto/builder"
],
plugins: [
replacePlugin,
typescriptPlugin,
terserPlugin,
visualizer({
filename: "./reports/bundle-builder-esm.html",
}),
{
name: "svg",
transform: (code, id) =>
id.endsWith(".svg") &&
imagemin
.buffer(Buffer.from(code), {
plugins: [
require("imagemin-svgo")(),
],
})
.then((data) => ({
map: { mappings: "" },
code: `export default "data:image/svg+xml;base64,${Buffer.from(data).toString("base64")}"`,
})),
},
],
onwarn,
},
{
input: ["./src/runner/index.ts"],
output: [
{
file: "./runner/esm/index.mjs",
format: "esm",
exports: "named",
},
],
external: [
"@tripetto/runner"
],
plugins: [
replacePlugin,
typescriptPlugin,
terserPlugin,
visualizer({
filename: "./reports/bundle-runner-esm.html",
}),
],
onwarn,
},
];