-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
50 lines (47 loc) · 1.25 KB
/
rollup.config.ts
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 typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import license from "rollup-plugin-license";
import resolve from "@rollup/plugin-node-resolve";
import svelte from "rollup-plugin-svelte";
import sveltePreprocess from "svelte-preprocess";
import type { Plugin, RollupOptions } from "rollup";
// @ts-ignore
const dev = process.env["npm_lifecycle_event"] === "dev";
const createBundle = (input: string, output: RollupOptions["output"], ...plugins: Plugin[]) => ({
input,
output,
plugins: [
svelte({
include: "src/**/*.svelte",
preprocess: sveltePreprocess(),
emitCss: false,
compilerOptions: {
dev,
css: "injected",
},
}),
typescript(),
resolve({
browser: true,
extensions: [".svelte", ".ts", ".js"],
dedupe: ["svelte"],
}),
...(dev
? []
: [
terser({
mangle: { properties: false },
compress: { passes: 10 },
output: { comments: false },
}),
license({ banner: { content: { file: "./LICENSE.txt" } } }),
]),
...plugins,
],
});
export default [
createBundle("src/contentscript/index.ts", {
file: "dist/contentscript.js",
format: "cjs",
}),
];