-
Notifications
You must be signed in to change notification settings - Fork 8
/
project.config.ts
189 lines (177 loc) · 4.37 KB
/
project.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
const VERSION = "1.3.3";
const FAVICON_SIZES = [16, 32];
const ICON_SIZES = [...FAVICON_SIZES, 48, 64, 96, 128, 256];
const ICONS = {
svg: makeIcons("svg-$normal", ".svg"),
png: makeIcons("png-$normal", ".png"),
};
const ICONS_DISABLED = {
svg: makeIcons("svg-$disabled", ".svg"),
png: makeIcons("png-$disabled", ".png"),
};
const FAVICONS: Array<{
input: string;
output: string;
size: number;
}> = ICONS.svg
.filter(([size]) => FAVICON_SIZES.includes(size))
.map(([size, svg]) => ({
input: svg,
output: `favicon-${size}.png`,
size,
}));
const mainIcon = "icons/main.svg";
const currentBrowser = getBrowser();
export default {
meta: {
version: VERSION,
name: "Link Hints",
slug: "LinkHints",
author: "Simon Lydell",
description: "Click with your keyboard.",
homepage: "https://lydell.github.io/LinkHints",
tutorial: "https://lydell.github.io/LinkHints/tutorial.html",
repo: "https://github.com/lydell/LinkHints",
newIssue: "https://github.com/lydell/LinkHints/issues/new/choose",
changelog: "https://github.com/lydell/LinkHints/issues/1",
issues: "https://github.com/lydell/LinkHints/issues/",
icon: mainIcon,
webExtBaseName: `link_hints-${VERSION}`,
geckoId: "[email protected]",
},
prod: currentBrowser !== undefined,
browser: currentBrowser,
src: "src",
compiled: "compiled",
dist: currentBrowser === undefined ? "dist" : `dist-${currentBrowser}`,
webextIgnoreFiles: [
"icons/*.!(svg)",
...browserSpecificIgnores(currentBrowser),
],
iconsDir: "icons",
mainIcon,
icons: ICONS,
iconsDisabled: ICONS_DISABLED,
iconsTestPage: "icons/test.html",
iconsChecksum: "icons/checksum.ts",
iconsCompilation: {
input: "icons.tsx",
output: "../icon.svg",
},
needsPolyfill: needsPolyfill(currentBrowser),
polyfill: {
input: "../node_modules/webextension-polyfill/dist/browser-polyfill.min.js",
output: "browser-polyfill.js",
},
background: {
input: "background/main.ts",
output: "background.js",
},
worker: {
input: "worker/main.ts",
output: "worker.js",
},
renderer: {
input: "renderer/main.ts",
output: "renderer.js",
},
popup: {
input: "popup/main.ts",
output: "popup.js",
},
popupCss: {
input: "popup/popup.css",
output: "popup.css",
},
popupHtml: "popup.html",
options: {
input: "options/main.tsx",
output: "options.js",
},
optionsCss: {
input: "options/options.css",
output: "options.css",
},
optionsHtml: "options.html",
manifest: {
input: "manifest.ts",
output: "manifest.json",
},
docs: {
src: "docs",
compiled: "compiled-docs",
root: currentBrowser === undefined ? "." : "/LinkHints",
icons: {
keycap: "keycap.svg",
icon: "icon.svg",
iconDisabled: "icon-disabled.svg",
},
favicons: FAVICONS,
iconsDir: "icons",
sharedCss: {
input: "shared.css",
output: "shared.css",
},
index: {
input: "index.tsx",
output: "index.html",
},
indexCss: {
input: "index.css",
output: "index.css",
},
tutorial: {
input: "tutorial.tsx",
output: "tutorial.html",
},
tutorialCss: {
input: "tutorial.css",
output: "tutorial.css",
},
},
colors: {
lightgrey: "#f7f7f7",
grey: "#bbb",
darkgrey: "#767676",
blue: "#2b4eed",
red: "#ec130e",
green: "#0f0",
// The purple used in Firefox for findbar "Highlight all" matches.
purple: "#ef0fff",
// The yellow used in Chrome for findbar matches.
yellow: "#f6ff00",
badge: "#323234",
},
};
function getBrowser(): Browser | undefined {
switch (process.env.BROWSER) {
case "chrome":
return "chrome";
case "firefox":
return "firefox";
default:
return undefined;
}
}
function browserSpecificIgnores(browser: Browser | undefined): Array<string> {
switch (browser) {
case "chrome":
return ["icons/svg-*"];
case "firefox":
return ["icons/png-*"];
case undefined:
return [];
}
}
function needsPolyfill(browser: Browser | undefined): boolean {
switch (browser) {
case "firefox":
return false;
case "chrome":
case undefined:
return true;
}
}
function makeIcons(name: string, extension: string): Array<[number, string]> {
return ICON_SIZES.map((size) => [size, `icons/${name}/${size}${extension}`]);
}