-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentScript.rollup.config.ts
More file actions
38 lines (34 loc) · 1.07 KB
/
contentScript.rollup.config.ts
File metadata and controls
38 lines (34 loc) · 1.07 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
import * as fs from "node:fs";
import terser from "@rollup/plugin-terser";
import replace from "@rollup/plugin-replace";
import typescript from "@rollup/plugin-typescript";
import type { RollupOptions } from "rollup";
const manifest = JSON.parse(fs.readFileSync("manifest.json", "utf-8")) as {
version: string;
description: string;
};
const isProduction = process.env.NODE_ENV === "production";
const config: RollupOptions = {
input: "src/ContentScript/main.ts",
output: {
file: "dist/src/ContentScript/index.js",
format: "iife",
},
plugins: [
replace({
"process.env.NODE_ENV": () => isProduction ? JSON.stringify("production") : JSON.stringify("development"),
__dirname: (id) => isProduction ? "''" : `'${id}'`,
__app_version: () => `'${manifest.version}'`,
__app_description: () => `'${manifest.description}'`,
preventAssignment: true,
}),
typescript({
tsconfig: "./tsconfig.json",
compilerOptions: {
allowJs: false,
},
}),
...(isProduction ? [terser()] : []),
],
};
export default config;