-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathrollup.config.js
106 lines (103 loc) · 2.6 KB
/
rollup.config.js
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
102
103
104
105
106
import postcss from "rollup-plugin-postcss";
import esbuild from "rollup-plugin-esbuild";
import metablock from "rollup-plugin-userscript-metablock";
import path from "path";
import replace from "@rollup/plugin-replace";
const buildConfig = {
replace: {
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.CHANNEL": JSON.stringify(process.env.CHANNEL),
"preventAssignment": true,
},
postcss: {
minimize: true,
extensions: [".css"],
},
esbuild: {
exclude: [/node_modules/],
sourceMap: false,
target: "es2015",
minify: false,
charset: "utf8",
tsconfig: path.resolve(__dirname, "tsconfig.json"),
},
};
const scriptConfig = [
{
name: "Copy",
meta: {
input: "./meta/blank.ts",
output: "./dist/meta/copy.meta.js",
metaFile: "./packages/copy/meta.json",
},
script: {
input: "./packages/copy/src/index.ts",
output: "./dist/copy.user.js",
injectCss: false,
},
},
{
name: "CopyCurrency",
meta: {
input: "./meta/blank.ts",
output: "./dist/meta/copy-currency.meta.js",
metaFile: "./packages/copy-currency/meta.json",
},
script: {
input: "./packages/copy-currency/src/index.ts",
output: "./dist/copy-currency.user.js",
},
},
{
name: "SiteDirector",
meta: {
input: "./meta/blank.ts",
output: "./dist/meta/site-director.meta.js",
metaFile: "./packages/site-director/meta.json",
},
script: {
input: "./packages/site-director/src/index.ts",
output: "./dist/site-director.user.js",
injectCss: false,
},
},
{
name: "WaterMark",
meta: {
input: "./meta/blank.ts",
output: "./dist/meta/water-mark.meta.js",
metaFile: "./packages/water-mark/meta.json",
},
script: {
input: "./packages/water-mark/src/index.ts",
output: "./dist/water-mark.user.js",
injectCss: false,
},
},
];
export default [
...scriptConfig.map(item => ({
input: item.meta.input,
output: {
file: item.meta.output,
format: "es",
name: item.name + "Meta",
},
plugins: [metablock({ file: item.meta.metaFile })],
})),
...scriptConfig.map(item => ({
input: item.script.input,
output: {
file: item.script.output,
format: "iife",
name: item.name + "Module",
},
plugins: [
replace({ ...buildConfig.replace }),
postcss({ ...buildConfig.postcss, inject: item.script.injectCss }),
esbuild(buildConfig.esbuild),
// terser({ format: { comments: true } }),
metablock({ file: item.meta.metaFile }),
],
})),
];