-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
78 lines (75 loc) · 2.26 KB
/
vite.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
import * as path from "node:path";
import { crx, defineManifest } from "@crxjs/vite-plugin";
import react from "@vitejs/plugin-react";
import rollupPluginLicense from "rollup-plugin-license";
import { defineConfig } from "vite";
import { FollowApiConfig } from "./scripts/follow-api.config";
const getManifest = defineManifest(async (env) => {
const isDev = env.mode === "development";
const VERSION = process.env.EXTENSION_VERSION;
if (!VERSION && ![undefined, null, "0", "false"].includes(process.env.CI)) {
throw new Error("EXTENSION_VERSION is required in CI build");
}
return {
manifest_version: 3,
name: isDev ? "[Dev] Follow it later" : "Follow it later",
version: VERSION || "0.0.0",
description: "Send a page to the inbox of Follow to read and subscribe later.",
permissions: ["activeTab", "scripting", "storage", "contextMenus"],
/**
* exact url like `https://example.com/foo/bar` will be changed into `https://example.com/*` by Chrome
* If possible, we'd like add each exact url to `host_permissions` instead of `HOST/*`
*/
host_permissions: [`${FollowApiConfig.root}/*`],
homepage_url: "https://tldr.ws/followit",
background: {
service_worker: "src/backend/entrypoint.ts",
},
icons: {
16: "icons/icon-16.png",
48: "icons/icon-48.png",
128: "icons/icon-128.png",
},
action: {
default_title: "Follow it later",
},
};
});
export default defineConfig((env) => {
const isDev = env.mode === "development";
return {
plugins: [react({}), crx({ manifest: getManifest, contentScripts: { injectCss: true } })],
clearScreen: false,
build: {
outDir: isDev ? "dev" : "dist",
rollupOptions: {
input: {
popup: "@/popup.html",
},
plugins: [
rollupPluginLicense({
thirdParty: {
output: "dist/dependencies.txt",
},
}),
],
output: {
assetFileNames: "assets/[name][extname]",
chunkFileNames: "assets/[name].js",
},
},
},
server: {
port: 5173,
strictPort: true,
hmr: {
port: 5173,
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
};
});