-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathvite.config.ts
124 lines (121 loc) · 4 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
115
116
117
118
119
120
121
122
123
124
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import monkey, { cdn, util } from "vite-plugin-monkey";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import process from "process";
import path from "path";
import fs from "fs";
const rootDir = process.cwd();
const pathSrc = path.resolve(__dirname, "src");
// https://vitejs.dev/config/
export default defineConfig(() => {
const env = loadEnv("", process.cwd(), "");
const VITE_RELEASE_MODE = env.VITE_RELEASE_MODE ?? "dev";
const VITE_VERSION = env.VITE_VERSION ?? "dev";
return {
plugins: [
vue(),
AutoImport({
imports: [util.unimportPreset],
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
monkey({
entry: "src/main.ts",
format: {
generate(uOptions) {
if (uOptions.mode === "build") {
const filePath = path.join(rootDir, "update.log");
const fileContent = fs.readFileSync(filePath, "utf-8");
const lines = fileContent.trim().split("\n");
const lastTenLines = lines.slice(-30);
const log = lastTenLines
.reverse()
.map((line) => `// ${line}`)
.join("\n");
return (
uOptions.userscript +
`\n// 更新日志[只显示最新的10条,🌟🤡 分别代表新功能和bug修复]\n${log}`
);
} else {
return uOptions.userscript;
}
},
},
userscript: {
name:
VITE_RELEASE_MODE === "release"
? "Boss直聘助手"
: `Boss直聘助手 [${VITE_RELEASE_MODE}]`,
version: VITE_VERSION,
license: "MIT",
description:
"优化UI去除广告,批量投递简历,高级筛选,GPT自动打招呼,多账号管理...",
icon: "https://img.bosszhipin.com/beijin/mcs/banner/3e9d37e9effaa2b6daf43f3f03f7cb15cfcd208495d565ef66e7dff9f98764da.jpg",
namespace: "https://github.com/Ocyss/boos-helper",
homepage: "https://github.com/Ocyss/boos-helper",
match: ["https://*.zhipin.com/*"],
author: "Ocyss",
grant: ["unsafeWindow"],
"run-at": "document-start",
connect: [
"api.chatanywhere.com.cn",
"api.moonshot.cn",
"aliyuncs.com",
"baidubce.com",
],
downloadURL:
"https://update.greasyfork.org/scripts/491340/Boss%E7%9B%B4%E8%81%98%E5%8A%A9%E6%89%8B.user.js",
updateURL:
"https://update.greasyfork.org/scripts/491340/Boss%E7%9B%B4%E8%81%98%E5%8A%A9%E6%89%8B.user.js",
},
build: {
externalGlobals: {
vue: cdn
.jsdelivr("Vue", "dist/vue.global.prod.js")
.concat(util.dataUrl(";window.Vue=Vue;")),
"element-plus": cdn.jsdelivr(
"ElementPlus",
"dist/index.full.min.js"
),
protobufjs: cdn.jsdelivr("protobuf", "dist/light/protobuf.min.js"),
},
externalResource: {
"element-plus/dist/index.css": cdn.jsdelivr(),
"element-plus/theme-chalk/dark/css-vars.css": cdn.jsdelivr(),
},
},
server: {
prefix: false,
},
}),
],
resolve: {
alias: {
"@": pathSrc,
},
},
build: {
minify: false,
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler", // or 'modern'
},
},
},
// server: {
// host: "logapi.zhipin.com",
// port: 80,
// https: {
// key: path.resolve(__dirname, "logapi.zhipin.com-key.pem"),
// cert: path.resolve(__dirname, "logapi.zhipin.com.pem"),
// },
// },
};
});