-
Notifications
You must be signed in to change notification settings - Fork 9
/
rollup.config.mjs
79 lines (75 loc) · 1.85 KB
/
rollup.config.mjs
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
import { readFileSync } from "fs";
import { basename, resolve as resolvePath } from "path";
import alias from "@rollup/plugin-alias";
import commonjs from "@rollup/plugin-commonjs";
import html from "@rollup/plugin-html";
import resolve from "@rollup/plugin-node-resolve";
import styles from "@ironkinoko/rollup-plugin-styles";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
const in_development = !!process.env.ROLLUP_WATCH;
export default Object.entries({
"src/extension.tsx": "panel.html",
"src/devtools.ts": "devtools.html",
"src/options.tsx": "options.html",
"src/popup.tsx": "popup.html",
}).map(([input, fileName], i) => ({
strictDeprecations: true,
input,
output: {
dir: "dist",
format: "iife",
entryFileNames: "[name].js",
sourcemap: in_development,
compact: !in_development,
plugins: in_development ? [] : [terser()],
},
plugins: [
i === 0
? copy({
input: [
"manifest.json",
"res/logo.svg",
"res/icon.png",
"res/icon-16.png",
"res/icon-48.png",
"res/icon-128.png",
"LICENSE.md",
],
})
: {},
resolve({ browser: true }),
commonjs(),
alias({
entries: {
url: resolvePath("./src/uri.js"),
buffer: "",
},
}),
typescript(),
styles({
mode: "extract",
minimize: !in_development,
sourceMap: in_development,
}),
html({
fileName,
title: "Snowplow Inspector",
}),
],
}));
function copy(opts) {
return {
name: "copy",
buildStart() {
opts.input.forEach((target) => {
this.addWatchFile(target);
this.emitFile({
type: "asset",
fileName: basename(target),
source: readFileSync(target),
});
});
},
};
}