@seayoo-web/scripts 3.1.10 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/git-C1rpf4Ed.js +343 -0
- package/dist/index.js +391 -398
- package/dist/node.js +538 -606
- package/package.json +17 -33
- package/types/index.d.ts +2 -2
- package/types/src/commit.d.ts +0 -1
- package/types/src/create.d.ts +0 -1
- package/types/src/destroy.d.ts +0 -1
- package/types/src/env.d.ts +0 -1
- package/types/src/oxfmt.d.ts +7 -0
- package/types/src/oxlint.d.ts +43 -0
- package/types/src/stylelint.d.ts +3 -0
- package/types/src/utils.d.ts +0 -1
- package/types/src/vite.lab.d.ts +1 -2
- package/dist/git-B0Cnp5wC.js +0 -310
package/dist/index.js
CHANGED
|
@@ -1,417 +1,410 @@
|
|
|
1
|
+
import { f as getNowTime, i as getCommitInfo, r as createPageDeployTag } from "./git-C1rpf4Ed.js";
|
|
1
2
|
import { join } from "node:path";
|
|
2
3
|
import vue from "@vitejs/plugin-vue";
|
|
3
4
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
5
|
+
import { defineConfig, loadEnv } from "vite";
|
|
4
6
|
import { finderDeploy, viteDeployPlugin } from "@seayoo-web/finder";
|
|
5
7
|
import { sentryVitePlugin } from "@sentry/vite-plugin";
|
|
6
8
|
import legacy from "@vitejs/plugin-legacy";
|
|
7
|
-
import { existsSync, readFileSync,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import pluginVue from "eslint-plugin-vue";
|
|
9
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
10
|
+
import { defineConfig as defineConfig$1 } from "oxlint";
|
|
11
|
+
import { defineConfig as defineConfig$2 } from "oxfmt";
|
|
12
|
+
//#region src/vite.app.ts
|
|
13
|
+
/**
|
|
14
|
+
* 导出一个动态的配置工厂函数
|
|
15
|
+
*/
|
|
15
16
|
function defineAppBuildConfig(option) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
const { plugins = [], build = {}, resolve = {}, ...optionReset } = option || {};
|
|
18
|
+
const { alias, ...resolveReset } = resolve || {};
|
|
19
|
+
return defineConfig({
|
|
20
|
+
base: "./",
|
|
21
|
+
build: {
|
|
22
|
+
emptyOutDir: true,
|
|
23
|
+
outDir: join(process.cwd(), "./dist"),
|
|
24
|
+
assetsDir: "assets",
|
|
25
|
+
reportCompressedSize: false,
|
|
26
|
+
sourcemap: false,
|
|
27
|
+
...build
|
|
28
|
+
},
|
|
29
|
+
plugins: [
|
|
30
|
+
vue(),
|
|
31
|
+
option?.visualizer ? visualizer() : null,
|
|
32
|
+
...plugins
|
|
33
|
+
],
|
|
34
|
+
resolve: {
|
|
35
|
+
alias: {
|
|
36
|
+
"@": join(process.cwd(), "./src"),
|
|
37
|
+
...alias
|
|
38
|
+
},
|
|
39
|
+
extensions: [
|
|
40
|
+
".mts",
|
|
41
|
+
".mjs",
|
|
42
|
+
".ts",
|
|
43
|
+
".js"
|
|
44
|
+
],
|
|
45
|
+
...resolveReset
|
|
46
|
+
},
|
|
47
|
+
...optionReset
|
|
48
|
+
});
|
|
39
49
|
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/vite.lab.ts
|
|
52
|
+
/**
|
|
53
|
+
* 导出一个动态的配置工厂函数用于 lib 类工具的编译配置
|
|
54
|
+
*
|
|
55
|
+
* 默认排除 "@seayoo-web/request"、"@seayoo-web/utils"、"@seayoo-web/validator"、"@seayoo-web/combo-webview" 不打包
|
|
56
|
+
*/
|
|
40
57
|
function defineLibBuildConfig(option) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
58
|
+
return defineConfig({ build: {
|
|
59
|
+
outDir: option?.outDir || "dist",
|
|
60
|
+
emptyOutDir: true,
|
|
61
|
+
lib: {
|
|
62
|
+
entry: join(process.cwd(), option?.rootEntry || "index.ts"),
|
|
63
|
+
formats: ["es"],
|
|
64
|
+
fileName(format, entryName) {
|
|
65
|
+
return format === "es" ? `${entryName}.js` : `${entryName}.${format}.js`;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
rolldownOptions: { external: option?.external || [/^@seayoo-web\/(?:request|utils|combo-webview|validator)/] }
|
|
69
|
+
} });
|
|
56
70
|
}
|
|
57
|
-
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/env.ts
|
|
73
|
+
var EnvPrefix = "SY_";
|
|
74
|
+
/**
|
|
75
|
+
* 获取构建环境配置
|
|
76
|
+
*/
|
|
58
77
|
function getBuildEnv(command, mode, requireSentryToken, ignoreSentryToken) {
|
|
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
|
-
if (ignoreSentryToken) {
|
|
139
|
-
envConfig.sentryAuthToken = "";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return envConfig;
|
|
78
|
+
const envs = loadEnv(mode, process.cwd(), "SY_");
|
|
79
|
+
const envConfig = {
|
|
80
|
+
command,
|
|
81
|
+
stamp: getNowTime(),
|
|
82
|
+
page: "",
|
|
83
|
+
mode: "",
|
|
84
|
+
deployUser: "",
|
|
85
|
+
deployKey: "",
|
|
86
|
+
viteEnvs: envs
|
|
87
|
+
};
|
|
88
|
+
envConfig.mode = mode || "preview";
|
|
89
|
+
const t = `SY_DEPLOY_TO`;
|
|
90
|
+
const s = `SY_SENTRY_AUTH_TOKEN`;
|
|
91
|
+
const u = `SY_DEPLOY_USER`;
|
|
92
|
+
const k = `SY_DEPLOY_KEY`;
|
|
93
|
+
const p = `SY_SERVER_PORT`;
|
|
94
|
+
const paths = process.cwd().replace(/\\/g, "/").split("/");
|
|
95
|
+
const execDirWithPackage = paths.slice(-2).join("/");
|
|
96
|
+
const execDir = paths.slice(-1)[0];
|
|
97
|
+
const packageFile = join(process.cwd(), "./package.json");
|
|
98
|
+
if (!existsSync(packageFile)) {
|
|
99
|
+
console.error("执行代码有误,没有找到 package.json".red);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
const packageJson = JSON.parse(readFileSync(packageFile, { encoding: "utf-8" }).toString());
|
|
103
|
+
if (!packageJson || !packageJson.name || !(packageJson.name + "").endsWith(`/${execDir}`)) {
|
|
104
|
+
console.error(`工程 package.json/name 属性设置错误,应该跟目录名保持一致,请先调整`.red);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
envConfig.page = execDirWithPackage;
|
|
108
|
+
const port = +envs[p];
|
|
109
|
+
if (port) envConfig.port = port;
|
|
110
|
+
envConfig.deployTo = (envs[t] || "").replace(/(?:^https?:\/\/|\/*$)/gi, "").replace(/^(.)/, "https://$1");
|
|
111
|
+
envConfig.deployUser = envs[u];
|
|
112
|
+
envConfig.deployKey = envs[k];
|
|
113
|
+
if (mode === "wellknown") {
|
|
114
|
+
const wellknownDir = join(process.cwd(), ".well-known");
|
|
115
|
+
if (!existsSync(wellknownDir)) {
|
|
116
|
+
console.error(`没有找到 .well-known 目录,它应该跟项目 package.json 文件在一个目录下`.red);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
if (!statSync(wellknownDir).isDirectory()) {
|
|
120
|
+
console.error(`.well-known 应该是一个目录`.red);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
if (readdirSync(wellknownDir).length === 0) {
|
|
124
|
+
console.error(`.well-known 不能是一个空目录`.red);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
if (!envConfig.deployTo) {
|
|
128
|
+
console.error(`缺少 ${t.bgRed} 设置,请在 .env.${mode} 中配置`.red);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
if (!envConfig.deployUser || !envConfig.deployKey) {
|
|
132
|
+
console.error(`缺少 ${u.bgRed} / ${k.bgRed} 设置,请在 .env.local 配置`.red);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
envConfig.wellKnownDir = wellknownDir;
|
|
136
|
+
return envConfig;
|
|
137
|
+
}
|
|
138
|
+
if (mode !== "build" && envConfig.command === "build") {
|
|
139
|
+
if (!envConfig.deployTo) {
|
|
140
|
+
console.error(`缺少 ${t.bgRed} 设置,请在 .env.${mode} 中配置`.red);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
if (!envConfig.deployUser || !envConfig.deployKey) {
|
|
144
|
+
console.error(`缺少 ${u.bgRed} / ${k.bgRed} 设置,请在 .env.local 配置`.red);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
envConfig.sentryAuthToken = envs[s];
|
|
148
|
+
if (!envConfig.sentryAuthToken) {
|
|
149
|
+
if (requireSentryToken) {
|
|
150
|
+
console.error(`缺少 ${s.red} 设置,请在 .env.local 配置`.red);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
} else if (!ignoreSentryToken) console.warn(`尚未设置 ${s.red},推送 sourcemap 到 sentry 的功能将无效`);
|
|
153
|
+
}
|
|
154
|
+
if (ignoreSentryToken) envConfig.sentryAuthToken = "";
|
|
155
|
+
}
|
|
156
|
+
return envConfig;
|
|
143
157
|
}
|
|
144
158
|
function transformEnvs(envs) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
{}
|
|
151
|
-
);
|
|
159
|
+
return Object.entries(envs).reduce(function(result, [key, value]) {
|
|
160
|
+
result[key] = JSON.stringify(value);
|
|
161
|
+
return result;
|
|
162
|
+
}, {});
|
|
152
163
|
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/inject.ts
|
|
166
|
+
/**
|
|
167
|
+
* 给模板文件注入数据
|
|
168
|
+
*/
|
|
153
169
|
function htmlInjectPlugin(data) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
170
|
+
return {
|
|
171
|
+
name: "html-inject-plugin",
|
|
172
|
+
transformIndexHtml: {
|
|
173
|
+
order: "pre",
|
|
174
|
+
handler: function(html) {
|
|
175
|
+
return html.replace(/%\s*(.*?)\s*%/g, (match, p1) => data[p1] ?? match).replace(/`{{\s*(.*?)\s*}}`/g, (match, p1) => data[p1] ?? match).replace(/[\r\n]{2,}/g, "\n").replace(/(?:^[\s\r\n]*|[\s\r\n]*$)/g, "");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
163
179
|
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/vite.page.ts
|
|
182
|
+
/**
|
|
183
|
+
* 导出一个动态的配置工厂函数
|
|
184
|
+
*/
|
|
164
185
|
function definePageBuildConfig(option) {
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
server: {
|
|
316
|
-
open: true,
|
|
317
|
-
port: envs.port,
|
|
318
|
-
...server
|
|
319
|
-
},
|
|
320
|
-
...optionReset,
|
|
321
|
-
// envPrefix 不允许覆盖
|
|
322
|
-
envPrefix: EnvPrefix
|
|
323
|
-
};
|
|
324
|
-
};
|
|
186
|
+
const { preset = {}, plugins = [], build = {}, resolve = {}, server = {}, sentry = {}, envTransformer, base, ...optionReset } = option || {};
|
|
187
|
+
const { alias, ...resolveReset } = resolve;
|
|
188
|
+
if (server.port) {
|
|
189
|
+
console.warn(`ServerPort 不允许直接修改,请使用环境变量 SY_SERVER_PORT 设置`);
|
|
190
|
+
delete server.port;
|
|
191
|
+
}
|
|
192
|
+
return async function({ command, mode }) {
|
|
193
|
+
const envs = getBuildEnv(command, mode, sentry.required, sentry.ignore);
|
|
194
|
+
const justBuild = mode === "build";
|
|
195
|
+
const gitInfo = justBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
|
|
196
|
+
const isProductMode = mode === "production" || mode === "prod" || mode === "prd";
|
|
197
|
+
if (mode === "wellknown" && envs.wellKnownDir && envs.deployTo) {
|
|
198
|
+
const result = await finderDeploy({
|
|
199
|
+
preview: false,
|
|
200
|
+
deployTo: envs.deployTo.replace(/\/$/, "") + "/.well-known",
|
|
201
|
+
dist: envs.wellKnownDir,
|
|
202
|
+
user: envs.deployUser,
|
|
203
|
+
key: envs.deployKey
|
|
204
|
+
}).catch((e) => e instanceof Error ? e : typeof e === "string" ? new Error(e) : /* @__PURE__ */ new Error(e + ""));
|
|
205
|
+
if (result instanceof Error) console.log("部署 .well-known 失败".bgRed, result.message);
|
|
206
|
+
else console.log("部署 .well-known 成功".bgGreen, (result || "").green);
|
|
207
|
+
process.exit(0);
|
|
208
|
+
}
|
|
209
|
+
if (envTransformer) envs.viteEnvs = await envTransformer(envs.viteEnvs, command, mode);
|
|
210
|
+
const trunkMap = {
|
|
211
|
+
"naive-ui": "naive-ui",
|
|
212
|
+
html2canvas: "html2canvas",
|
|
213
|
+
swiper: "swiper",
|
|
214
|
+
...preset.manualChunks
|
|
215
|
+
};
|
|
216
|
+
const ignoreSideEffects = [
|
|
217
|
+
"thinkingdata",
|
|
218
|
+
"@esotericsoftware/spine",
|
|
219
|
+
...preset.badPackages || []
|
|
220
|
+
];
|
|
221
|
+
const baseValue = typeof base === "function" ? base(mode, envs.viteEnvs) : typeof base === "object" && base ? base[mode] : typeof base === "string" ? base : "./";
|
|
222
|
+
if (baseValue === void 0 && mode !== "development") {
|
|
223
|
+
console.warn(`base 参数在模式(${mode})下未设置内容`.red);
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
return defineConfig({
|
|
227
|
+
base: baseValue || "./",
|
|
228
|
+
build: {
|
|
229
|
+
emptyOutDir: true,
|
|
230
|
+
outDir: join(process.cwd(), "./dist"),
|
|
231
|
+
assetsDir: "assets",
|
|
232
|
+
reportCompressedSize: false,
|
|
233
|
+
sourcemap: command === "build" && !!envs.sentryAuthToken ? "hidden" : false,
|
|
234
|
+
...build,
|
|
235
|
+
rolldownOptions: {
|
|
236
|
+
treeshake: { moduleSideEffects: function(id) {
|
|
237
|
+
return !ignoreSideEffects.some((k) => id.includes(k));
|
|
238
|
+
} },
|
|
239
|
+
...build.rolldownOptions,
|
|
240
|
+
output: {
|
|
241
|
+
manualChunks: function(id) {
|
|
242
|
+
const k = Object.keys(trunkMap).find((j) => id.includes(j));
|
|
243
|
+
if (k) return trunkMap[k];
|
|
244
|
+
},
|
|
245
|
+
...build.rolldownOptions?.output
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
plugins: [
|
|
250
|
+
preset.ignoreVuePlugin ? null : vue(),
|
|
251
|
+
preset.ignorePolyfill ? null : legacy(preset.polyfill ?? {
|
|
252
|
+
targets: [
|
|
253
|
+
"defaults",
|
|
254
|
+
"chrome >= 52",
|
|
255
|
+
"> 0.1%",
|
|
256
|
+
"last 5 versions and not dead"
|
|
257
|
+
],
|
|
258
|
+
additionalLegacyPolyfills: [
|
|
259
|
+
"regenerator-runtime/runtime",
|
|
260
|
+
"core-js/es/global-this",
|
|
261
|
+
"core-js/es/array/flat",
|
|
262
|
+
"core-js/es/array/flat-map",
|
|
263
|
+
"core-js/es/promise/all-settled",
|
|
264
|
+
"core-js/es/promise/any",
|
|
265
|
+
"core-js/es/symbol/iterator"
|
|
266
|
+
],
|
|
267
|
+
additionalModernPolyfills: [
|
|
268
|
+
"core-js/es/global-this",
|
|
269
|
+
"core-js/es/array/flat",
|
|
270
|
+
"core-js/es/array/flat-map",
|
|
271
|
+
"core-js/es/promise/all-settled",
|
|
272
|
+
"core-js/es/promise/any",
|
|
273
|
+
"core-js/es/symbol/iterator"
|
|
274
|
+
]
|
|
275
|
+
}),
|
|
276
|
+
htmlInjectPlugin({
|
|
277
|
+
BUILD_TIME: envs.stamp,
|
|
278
|
+
BUILD_MODE: envs.mode,
|
|
279
|
+
BUILD_VERSION: gitInfo?.hash || "",
|
|
280
|
+
...envs.viteEnvs
|
|
281
|
+
}),
|
|
282
|
+
...plugins,
|
|
283
|
+
command === "build" && envs.deployTo && !justBuild && gitInfo ? viteDeployPlugin({
|
|
284
|
+
deployTo: envs.deployTo,
|
|
285
|
+
ignoreFiles: ["*.js.map", ...option?.finder?.ignoreFiles || []],
|
|
286
|
+
user: envs.deployUser,
|
|
287
|
+
key: envs.deployKey,
|
|
288
|
+
debug: option?.finder?.debug,
|
|
289
|
+
preview: option?.finder?.preview ?? true,
|
|
290
|
+
ignoreCache: option?.finder?.ignoreServerListCache,
|
|
291
|
+
commitLogs: isProductMode && gitInfo.logs.length > 0 ? "\n" + gitInfo.logs.join("\n") : void 0,
|
|
292
|
+
onBeforeDeploy: option?.finder?.beforeDeploy ? async function(dist) {
|
|
293
|
+
await option?.finder?.beforeDeploy?.(dist, envs.viteEnvs);
|
|
294
|
+
} : void 0,
|
|
295
|
+
onFinished() {
|
|
296
|
+
if (isProductMode) createPageDeployTag(envs.page, envs.deployTo || "", envs.deployUser);
|
|
297
|
+
}
|
|
298
|
+
}) : null,
|
|
299
|
+
command === "build" && envs.sentryAuthToken && !justBuild ? sentryVitePlugin({
|
|
300
|
+
authToken: envs.sentryAuthToken,
|
|
301
|
+
org: sentry.org || "sentry",
|
|
302
|
+
url: sentry.url || "https://sentry.seayoo.com",
|
|
303
|
+
project: sentry.project || "gamer-fe",
|
|
304
|
+
...plugins
|
|
305
|
+
}) : null,
|
|
306
|
+
justBuild ? visualizer() : null
|
|
307
|
+
],
|
|
308
|
+
define: transformEnvs({
|
|
309
|
+
BUILD_TIME: envs.stamp,
|
|
310
|
+
BUILD_MODE: envs.mode,
|
|
311
|
+
...envs.viteEnvs
|
|
312
|
+
}),
|
|
313
|
+
resolve: {
|
|
314
|
+
alias: {
|
|
315
|
+
"@": join(process.cwd(), "./src"),
|
|
316
|
+
...alias
|
|
317
|
+
},
|
|
318
|
+
extensions: [
|
|
319
|
+
".mts",
|
|
320
|
+
".mjs",
|
|
321
|
+
".ts",
|
|
322
|
+
".js"
|
|
323
|
+
],
|
|
324
|
+
...resolveReset
|
|
325
|
+
},
|
|
326
|
+
server: {
|
|
327
|
+
open: true,
|
|
328
|
+
port: envs.port,
|
|
329
|
+
...server
|
|
330
|
+
},
|
|
331
|
+
...optionReset,
|
|
332
|
+
envPrefix: "SY_"
|
|
333
|
+
});
|
|
334
|
+
};
|
|
325
335
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
alphabetize: {
|
|
356
|
-
order: "asc",
|
|
357
|
-
caseInsensitive: true
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
const importEslintConfig = [
|
|
361
|
-
flatConfigs.recommended,
|
|
362
|
-
{
|
|
363
|
-
rules: {
|
|
364
|
-
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
365
|
-
"import/no-unresolved": "off",
|
|
366
|
-
"import/named": "off",
|
|
367
|
-
"import/namespace": "off",
|
|
368
|
-
"import/no-named-as-default": "off",
|
|
369
|
-
"import/no-named-as-default-member": "off",
|
|
370
|
-
"import/export": "error",
|
|
371
|
-
"import/order": ["error", importOrderRuleConfig]
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
];
|
|
375
|
-
function defineEslintConfig(...options) {
|
|
376
|
-
return defineConfigWithVueTs(vueEslintConfig, importEslintConfig, options);
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/oxlint.ts
|
|
338
|
+
function defineOxlintConfig(options) {
|
|
339
|
+
return defineConfig$1({
|
|
340
|
+
plugins: [
|
|
341
|
+
"typescript",
|
|
342
|
+
"import",
|
|
343
|
+
...options?.plugins || ["vue"]
|
|
344
|
+
],
|
|
345
|
+
categories: {
|
|
346
|
+
correctness: "error",
|
|
347
|
+
perf: "warn",
|
|
348
|
+
suspicious: "warn"
|
|
349
|
+
},
|
|
350
|
+
ignorePatterns: [
|
|
351
|
+
"**/dist/**",
|
|
352
|
+
"**/bin/**",
|
|
353
|
+
"**/types/**",
|
|
354
|
+
"**/coverage/**"
|
|
355
|
+
],
|
|
356
|
+
rules: {
|
|
357
|
+
"vue/multi-word-component-names": "off",
|
|
358
|
+
"import/no-unresolved": "off",
|
|
359
|
+
...options?.rules
|
|
360
|
+
},
|
|
361
|
+
env: options?.env || { browser: true },
|
|
362
|
+
overrides: options?.overrides,
|
|
363
|
+
globals: options?.globals
|
|
364
|
+
});
|
|
377
365
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/oxfmt.ts
|
|
368
|
+
/**
|
|
369
|
+
* 获取 oxfmt 配置
|
|
370
|
+
*
|
|
371
|
+
* https://oxc.rs/docs/guide/usage/formatter/config-file-reference.html
|
|
372
|
+
*/
|
|
373
|
+
function defineOxfmtConfig() {
|
|
374
|
+
return defineConfig$2({
|
|
375
|
+
sortImports: {
|
|
376
|
+
newlinesBetween: false,
|
|
377
|
+
ignoreCase: true,
|
|
378
|
+
groups: [
|
|
379
|
+
"builtin",
|
|
380
|
+
"external",
|
|
381
|
+
["internal", "subpath"],
|
|
382
|
+
{ newlinesBetween: true },
|
|
383
|
+
"parent",
|
|
384
|
+
"sibling",
|
|
385
|
+
"index",
|
|
386
|
+
{ newlinesBetween: true },
|
|
387
|
+
["style", "side_effect_style"],
|
|
388
|
+
{ newlinesBetween: true },
|
|
389
|
+
"type",
|
|
390
|
+
{ newlinesBetween: true },
|
|
391
|
+
"unknown"
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
ignorePatterns: [
|
|
395
|
+
"**/dist/**",
|
|
396
|
+
"**/bin/**",
|
|
397
|
+
"**/types/**",
|
|
398
|
+
"**/coverage/**"
|
|
399
|
+
],
|
|
400
|
+
semi: true,
|
|
401
|
+
useTabs: false,
|
|
402
|
+
printWidth: 120,
|
|
403
|
+
singleQuote: false,
|
|
404
|
+
trailingComma: "all",
|
|
405
|
+
bracketSpacing: true,
|
|
406
|
+
endOfLine: "lf"
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
export { EnvPrefix, defineAppBuildConfig, defineLibBuildConfig, defineOxfmtConfig, defineOxlintConfig, definePageBuildConfig, getBuildEnv, htmlInjectPlugin, transformEnvs };
|