@seayoo-web/scripts 2.0.5 → 2.0.7
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 +18 -4
- package/package.json +1 -1
- package/types/src/env.d.ts +1 -1
- package/types/src/vite.page.d.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ function defineLibBuildConfig(option) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
const EnvPrefix = "SY_";
|
|
58
|
-
function getBuildEnv(command, mode) {
|
|
58
|
+
function getBuildEnv(command, mode, onlyBuild) {
|
|
59
59
|
const envs = loadEnv(mode, process.cwd(), EnvPrefix);
|
|
60
60
|
const envConfig = {
|
|
61
61
|
command,
|
|
@@ -86,6 +86,9 @@ function getBuildEnv(command, mode) {
|
|
|
86
86
|
process.exit(1);
|
|
87
87
|
}
|
|
88
88
|
envConfig.page = execDirWithPackage;
|
|
89
|
+
if (onlyBuild) {
|
|
90
|
+
return envConfig;
|
|
91
|
+
}
|
|
89
92
|
if (envConfig.command === "build") {
|
|
90
93
|
if (process.env.NODE_ENV !== "production") {
|
|
91
94
|
console.error("部署时需要设置 NODE_ENV 为 production,请检查环境变量设置".red);
|
|
@@ -143,11 +146,22 @@ function definePageBuildConfig(option) {
|
|
|
143
146
|
const { alias, ...resolveReset } = resolve;
|
|
144
147
|
return async function({ command, mode }) {
|
|
145
148
|
var _a;
|
|
146
|
-
const envs = getBuildEnv(command, mode);
|
|
149
|
+
const envs = getBuildEnv(command, mode, onlyBuild);
|
|
147
150
|
const gitInfo = onlyBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
|
|
148
151
|
const isProductMode = mode === "production" || mode === "prod";
|
|
149
|
-
const trunkMap =
|
|
150
|
-
|
|
152
|
+
const trunkMap = {
|
|
153
|
+
...manualChunks,
|
|
154
|
+
"naive-ui": "naive-ui",
|
|
155
|
+
html2canvas: "html2canvas",
|
|
156
|
+
thinkingdata: "thinkingdata",
|
|
157
|
+
pinia: "vue",
|
|
158
|
+
"vue-router": "vue",
|
|
159
|
+
"plugin-vue:": "vue",
|
|
160
|
+
"/vue/": "vue",
|
|
161
|
+
"/@vue": "vue",
|
|
162
|
+
node_modules: "vendor"
|
|
163
|
+
};
|
|
164
|
+
const trunkKeys = Object.keys(trunkMap).sort((a, b) => a === "node_modules" ? 1 : b === "node_modules" ? -1 : 0);
|
|
151
165
|
const trunkFn = function(id) {
|
|
152
166
|
const k = trunkKeys.find((k2) => id.includes(k2));
|
|
153
167
|
if (k) return trunkMap[k];
|
package/package.json
CHANGED
package/types/src/env.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ interface IBuildEnvs {
|
|
|
25
25
|
/**
|
|
26
26
|
* 获取构建环境配置
|
|
27
27
|
*/
|
|
28
|
-
export declare function getBuildEnv(command: "serve" | "build", mode: string): IBuildEnvs;
|
|
28
|
+
export declare function getBuildEnv(command: "serve" | "build", mode: string, onlyBuild?: boolean): IBuildEnvs;
|
|
29
29
|
export declare function transformEnvs(envs: Record<string, unknown>): Record<string, string>;
|
|
30
30
|
export {};
|
package/types/src/vite.page.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ interface ExternalConfig {
|
|
|
10
10
|
/**
|
|
11
11
|
* 手工指定 trunk 合并策略,Record<key, chunk>,即 id.include(key) 则打到 trunk 中
|
|
12
12
|
*
|
|
13
|
-
* 默认 {
|
|
13
|
+
* 默认 {"naive-ui", html2canvas, thinkingdata, vue, node_modules: "vendor"}
|
|
14
|
+
*
|
|
15
|
+
* 设置的值会给默认值进行合并
|
|
14
16
|
*
|
|
15
17
|
* 也可以手工设定 build.rollupOptions.output.manualChunks 来自定义
|
|
16
18
|
*/
|