-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
96 lines (91 loc) · 2.54 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import path from "path";
import react from "@vitejs/plugin-react-swc";
import { defineConfig, PluginOption } from "vite";
import { writeFileSync } from "fs";
import packageJson from "./package.json";
const isDev = process.env.NODE_ENV === "development";
const manifest: chrome.runtime.ManifestV3 = {
manifest_version: 3,
name: packageJson.productName,
author: packageJson.author.name,
homepage_url: packageJson.author.url,
version: packageJson.version,
description: packageJson.description,
background: {
service_worker: "background.js",
},
// content_scripts: [
// {
// matches: ["<all_urls>"],
// js: ["content.js"],
// },
// ],
action: {
default_popup: "index.html",
},
side_panel: {
default_path: "side_panel.html",
},
permissions: [
"tabs",
"activeTab",
"storage",
"scripting",
"unlimitedStorage",
"alarms",
"sidePanel",
],
commands: {
"add-current-tab-to-active-collection": {
suggested_key: {
default: "Ctrl+Shift+A",
},
description:
"Add current tab to active/opened collection in side panel",
},
},
host_permissions: ["<all_urls>"],
icons: {
16: "/icon16.png",
32: "/icon32.png",
48: "/icon48.png",
128: "/icon128.png",
},
};
const manifestPlugin = (): PluginOption => {
return {
name: "make-extension-manifest",
buildEnd() {
writeFileSync(
path.join(path.resolve("./public"), "manifest.json"),
JSON.stringify(manifest, null, "\t")
);
},
};
};
export default defineConfig({
plugins: [react(), manifestPlugin()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
minify: !isDev,
rollupOptions: {
input: {
index: path.resolve(__dirname, "./index.html"),
side_panel: path.resolve(__dirname, "./side_panel.html"),
background: path.resolve(__dirname, "./src/background.ts"),
content: path.resolve(__dirname, "./src/content.ts"),
},
output: {
entryFileNames: (asset) => {
if (["background", "content"].includes(asset.name))
return `[name].js`;
return `assets/[name]-[hash].js`;
},
},
},
},
});