-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathrollup.config-dev.js
More file actions
56 lines (49 loc) · 1.59 KB
/
rollup.config-dev.js
File metadata and controls
56 lines (49 loc) · 1.59 KB
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
import commonJs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import postcss from "rollup-plugin-postcss";
import postcssUrl from "postcss-url";
import { visualizer } from "./dist/plugin/index.js";
const HTML_TEMPLATE = ["treemap", "treemap-3d", "sunburst", "network", "flamegraph"];
const PLAIN_TEMPLATE = ["raw-data", "list", "markdown"];
const ALL_TEMPLATE = [...HTML_TEMPLATE, ...PLAIN_TEMPLATE];
const chooseExt = (template) => {
if (template === "raw-data") return ".json";
if (template === "list") return ".yml";
if (template === "markdown") return ".md";
return ".html";
};
/** @type {import('rollup').RollupOptions} */
export default ALL_TEMPLATE.map((templateType) => ({
input: Object.fromEntries(HTML_TEMPLATE.map((t) => [t, `./src/${t}/index.tsx`])),
plugins: [
typescript({ tsconfig: "./src/tsconfig.json", outDir: "./temp/", noEmitOnError: true }),
resolve({ mainFields: ["module", "main"] }),
commonJs({
ignoreGlobal: true,
include: ["node_modules/**"],
}),
postcss({
extract: true,
plugins: [
postcssUrl({
url: "inline",
}),
],
}),
visualizer({
title: `dev build ${templateType}`,
filename: `stats.${templateType}${chooseExt(templateType)}`,
template: templateType,
gzipSize: true,
brotliSize: true,
sourcemap: !!process.env.SOURCEMAP,
open: !!process.env.OPEN,
}),
],
output: {
format: "es",
dir: `./temp/`,
sourcemap: !!process.env.SOURCEMAP,
},
}));