-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
101 lines (98 loc) · 2.54 KB
/
Copy pathrollup.config.js
File metadata and controls
101 lines (98 loc) · 2.54 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
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
96
97
98
99
100
101
import alias from "@rollup/plugin-alias";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import sucrase from "@rollup/plugin-sucrase";
import browserslist from "browserslist";
import { browserslistToTargets, Features } from "lightningcss";
import cleanup from "rollup-plugin-cleanup";
import copy from "rollup-plugin-copy";
import del from "rollup-plugin-delete";
import { string } from "rollup-plugin-string";
import styles from "rollup-plugin-styles";
import lightning from "unplugin-lightningcss/rollup";
const noise = new Set([
"index",
"dist",
"src",
"source",
"distribution",
"node_modules",
"main",
"esm",
"cjs",
"build",
]);
const rollup = {
input: {
options: "./source/options.tsx",
background: "./source/background.ts",
"refined-forgejo": "./source/refined-forgejo.ts",
"content-script": "./source/content-script.ts",
},
output: {
dir: "distribution/assets",
preserveModules: true,
preserveModulesRoot: "source",
assetFileNames: "[name][extname]",
entryFileNames(chunkInfo) {
if (chunkInfo.name.includes("node_modules")) {
const cleanName = chunkInfo.name
.split("/")
.filter(part => !noise.has(part))
.map(part => part.replace(/^\./, ""))
.join("-");
return `npm/${cleanName}.js`;
}
return chunkInfo.name + ".js";
},
},
watch: {
clearScreen: false,
},
context: "globalThis",
plugins: [
del({
targets: ["distribution/assets"],
runOnce: true,
}),
lightning({
options: {
include: Features.Nesting,
targets: browserslistToTargets(browserslist("chrome 123, firefox 126, iOS 17.5")),
},
}),
json(),
styles({
mode: "extract",
url: false,
}),
alias({
entries: [
{ find: "react", replacement: "dom-chef" },
],
}),
sucrase({
transforms: ["typescript", "jsx"],
// jsxPragma: "h",
// jsxFragmentPragma: "Fragment",
disableESTransforms: true,
production: true,
}),
resolve({ browser: true }),
commonjs(),
copy({
targets: [
{ src: "./source/manifest.json", dest: "distribution" },
{ src: "./source/*.html", dest: "distribution" },
{ src: "./source/*.png", dest: "distribution/assets" },
{ src: "./source/options.css", dest: "distribution/assets" },
],
}),
cleanup(),
string({
include: "**/*.svg",
}),
],
};
export default rollup;