@seayoo-web/scripts 2.1.0 → 2.2.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/index.js +15 -8
- package/package.json +2 -2
- package/types/src/vite.page.d.ts +19 -1
package/dist/index.js
CHANGED
|
@@ -134,8 +134,8 @@ function htmlInjectPlugin(data) {
|
|
|
134
134
|
}
|
|
135
135
|
function definePageBuildConfig(option) {
|
|
136
136
|
const {
|
|
137
|
-
onlyBuild,
|
|
138
137
|
manualChunks,
|
|
138
|
+
badPackages = [],
|
|
139
139
|
plugins = [],
|
|
140
140
|
define = {},
|
|
141
141
|
build = {},
|
|
@@ -146,15 +146,15 @@ function definePageBuildConfig(option) {
|
|
|
146
146
|
} = option || {};
|
|
147
147
|
const { alias, ...resolveReset } = resolve;
|
|
148
148
|
return async function({ command, mode }) {
|
|
149
|
-
var _a;
|
|
150
|
-
const justBuild =
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
const justBuild = mode === "build";
|
|
151
151
|
const envs = getBuildEnv(command, mode, justBuild);
|
|
152
152
|
const gitInfo = justBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
|
|
153
153
|
const isProductMode = mode === "production" || mode === "prod";
|
|
154
154
|
const trunkMap = {
|
|
155
155
|
"naive-ui": "naive-ui",
|
|
156
156
|
html2canvas: "html2canvas",
|
|
157
|
-
|
|
157
|
+
swiper: "swiper",
|
|
158
158
|
...manualChunks
|
|
159
159
|
};
|
|
160
160
|
const trunkKeys = Object.keys(trunkMap);
|
|
@@ -162,6 +162,7 @@ function definePageBuildConfig(option) {
|
|
|
162
162
|
const k = trunkKeys.find((k2) => id.includes(k2));
|
|
163
163
|
if (k) return trunkMap[k];
|
|
164
164
|
};
|
|
165
|
+
const ignoreSideEffects = ["thinkingdata", "@esotericsoftware/spine", ...badPackages];
|
|
165
166
|
return {
|
|
166
167
|
base: "./",
|
|
167
168
|
build: {
|
|
@@ -172,11 +173,16 @@ function definePageBuildConfig(option) {
|
|
|
172
173
|
sourcemap: command === "build" && !!envs.sentryAuthToken ? "hidden" : false,
|
|
173
174
|
...build,
|
|
174
175
|
rollupOptions: {
|
|
176
|
+
treeshake: {
|
|
177
|
+
moduleSideEffects: function(id) {
|
|
178
|
+
return !ignoreSideEffects.some((k) => id.includes(k));
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
...build.rollupOptions,
|
|
175
182
|
output: {
|
|
176
183
|
manualChunks: trunkFn,
|
|
177
184
|
...(_a = build.rollupOptions) == null ? void 0 : _a.output
|
|
178
|
-
}
|
|
179
|
-
...build.rollupOptions
|
|
185
|
+
}
|
|
180
186
|
}
|
|
181
187
|
},
|
|
182
188
|
plugins: [
|
|
@@ -214,10 +220,11 @@ function definePageBuildConfig(option) {
|
|
|
214
220
|
command === "build" && envs.deployTo && !justBuild && gitInfo ? viteDeployPlugin({
|
|
215
221
|
deployTo: envs.deployTo,
|
|
216
222
|
// 忽略 js sourcemap 文件
|
|
217
|
-
ignoreFiles: ["*.js.map"],
|
|
223
|
+
ignoreFiles: ["*.js.map", ...((_b = option == null ? void 0 : option.finder) == null ? void 0 : _b.ignoreFiles) || []],
|
|
218
224
|
user: envs.deployUser,
|
|
219
225
|
key: envs.deployKey,
|
|
220
226
|
debug: envs.deployDebug,
|
|
227
|
+
preview: (_c = option == null ? void 0 : option.finder) == null ? void 0 : _c.preview,
|
|
221
228
|
commitLogs: isProductMode && gitInfo.logs.length > 0 ? "\n" + gitInfo.logs.join("\n") : void 0,
|
|
222
229
|
onFinished() {
|
|
223
230
|
if (isProductMode) {
|
|
@@ -227,7 +234,7 @@ function definePageBuildConfig(option) {
|
|
|
227
234
|
}) : null,
|
|
228
235
|
command === "build" && envs.sentryAuthToken && !justBuild ? sentryVitePlugin({
|
|
229
236
|
authToken: envs.sentryAuthToken,
|
|
230
|
-
org: "sentry",
|
|
237
|
+
org: sentry.org || "sentry",
|
|
231
238
|
url: sentry.url || "https://sentry.seayoo.com/",
|
|
232
239
|
project: sentry.project || "gamer-fe"
|
|
233
240
|
}) : null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/scripts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "scripts for seayoo web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"terser": "^5.39.0",
|
|
52
52
|
"vite-plugin-stylelint": "^6.0.0",
|
|
53
53
|
"vite-plugin-vue-devtools": "^7.7.5",
|
|
54
|
-
"@seayoo-web/finder": "^2.0
|
|
54
|
+
"@seayoo-web/finder": "^2.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/fs-extra": "^11.0.4",
|
package/types/src/vite.page.d.ts
CHANGED
|
@@ -4,19 +4,37 @@ interface ExternalConfig {
|
|
|
4
4
|
sentry?: {
|
|
5
5
|
project?: string;
|
|
6
6
|
url?: string;
|
|
7
|
+
org?: string;
|
|
8
|
+
};
|
|
9
|
+
/** finder 配置 */
|
|
10
|
+
finder?: {
|
|
11
|
+
/** 是否部署完毕后打开目标文件(index.html)也可以指定不同的目标文件 */
|
|
12
|
+
preview?: boolean | string | string[];
|
|
13
|
+
/**
|
|
14
|
+
* 忽略部署的文件,如果是目录则需要以 / 结尾,支持 * 占位符模糊匹配。
|
|
15
|
+
*
|
|
16
|
+
* 匹配时仅针对单一目录和文件名进行检查,不跨目录检查
|
|
17
|
+
*/
|
|
18
|
+
ignoreFiles?: string[];
|
|
7
19
|
};
|
|
8
20
|
/** 仅仅编译 */
|
|
9
21
|
onlyBuild?: boolean;
|
|
10
22
|
/**
|
|
11
23
|
* 手工指定 trunk 合并策略,Record<key, chunk>,即 id.include(key) 则打到 trunk 中
|
|
12
24
|
*
|
|
13
|
-
* 默认 {`naive-ui`, `html2canvas`, `
|
|
25
|
+
* 默认 {`naive-ui`, `html2canvas`, `swiper`}
|
|
14
26
|
*
|
|
15
27
|
* 设置的值会跟默认值进行合并。
|
|
16
28
|
*
|
|
17
29
|
* 也可以手工设定 `build.rollupOptions.output.manualChunks` 来自定义
|
|
18
30
|
*/
|
|
19
31
|
manualChunks?: Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* 指定哪些不够友好的包,这些包的 iife 或修改全局 windows 变量的行为导致默认 tree-shaking 策略失效
|
|
34
|
+
*
|
|
35
|
+
* 从而这些包被误打入最终的产物中,无谓增加了包的体积。默认 `thinkingdata` 和 `@esotericsoftware`
|
|
36
|
+
*/
|
|
37
|
+
badPackages?: string[];
|
|
20
38
|
}
|
|
21
39
|
/**
|
|
22
40
|
* 导出一个动态的配置工厂函数
|