-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
114 lines (103 loc) · 2.93 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import fs from "node:fs";
import path from "node:path";
// Vite And it's plugins
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import vue from "@vitejs/plugin-vue";
import vuetify from "vite-plugin-vuetify";
import VueDevTools from "vite-plugin-vue-devtools";
import webExtension from "vite-plugin-web-extension";
// @ts-ignore
import tailwindcss from "@tailwindcss/vite";
import { vitePluginGenerateWebextLocales } from "./vite/generateWebextLocales";
import git from "git-rev-sync";
import pkg from "./package.json";
function base_path(_path = "") {
return path.resolve(__dirname, _path);
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vitePluginGenerateWebextLocales(),
nodePolyfills({
include: ["buffer", "path"],
globals: {
Buffer: true,
},
}),
tailwindcss(),
VueDevTools({
launchEditor: fs.existsSync(base_path("./.idea")) ? "webstorm" : "vscode",
}),
vue(),
vuetify(),
webExtension({
disableAutoLaunch: true,
skipManifestValidation: true,
manifest: () => ({
"{{chrome}}.manifest_version": 3,
minimum_chrome_version: "120",
version: pkg.version,
name: "__MSG_extName__",
description: "__MSG_extDesc__",
default_locale: "en",
homepage_url: "https://github.com/ronggang/PT-Plugin-Plus",
icons: {
"16": "icons/logo/16.png",
"19": "icons/logo/19.png",
"64": "icons/logo/64.png",
"128": "icons/logo/128.png",
},
action: {
default_icon: {
"16": "icons/logo/16.png",
"19": "icons/logo/19.png",
"64": "icons/logo/64.png",
"128": "icons/logo/128.png",
},
default_title: "__MSG_extName__",
},
"{{chrome}}.background": {
service_worker: "src/entries/background/main.ts",
},
options_ui: {
page: "src/entries/options/index.html",
open_in_tab: true,
},
permissions: [
"activeTab",
"alarms",
"clipboardWrite",
"contextMenus",
"cookies",
"notifications",
"scripting",
"storage",
"unlimitedStorage",
"offscreen",
],
host_permissions: ["*://*/*"],
}),
additionalInputs: ["src/entries/offscreen/offscreen.html"],
watchFilePaths: ["package.json"],
}),
],
resolve: {
alias: {
"~": base_path("./src"),
"@": base_path("./src/entries"),
"@ptd": base_path("./src/packages"),
},
},
define: {
__GIT_VERSION__: {
short: git.short(__dirname),
long: git.long(__dirname),
date: +git.date(),
count: git.count(),
branch: git.branch(__dirname),
},
__BUILD_TIME__: +Date.now(),
__RESOURCE_SITE_ICONS__: fs.readdirSync(base_path("./public/icons/site")),
},
});