@seayoo-web/scripts 2.2.1 → 2.4.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 CHANGED
@@ -56,7 +56,7 @@ function defineLibBuildConfig(option) {
56
56
  };
57
57
  }
58
58
  const EnvPrefix = "SY_";
59
- function getBuildEnv(command, mode, onlyBuild) {
59
+ function getBuildEnv(command, mode, onlyBuild, requireSentryToken, ignoreSentryToken) {
60
60
  const envs = loadEnv(mode, process.cwd(), EnvPrefix);
61
61
  const envConfig = {
62
62
  command,
@@ -109,7 +109,15 @@ function getBuildEnv(command, mode, onlyBuild) {
109
109
  }
110
110
  envConfig.sentryAuthToken = envs[s];
111
111
  if (!envConfig.sentryAuthToken) {
112
- console.warn(`尚未设置 ${s.red},推送 sourcemap 到 sentry 的功能将无效`);
112
+ if (requireSentryToken) {
113
+ console.error(`缺少 ${s.red} 设置,请在 .env.local 配置`.red);
114
+ process.exit(1);
115
+ } else if (!ignoreSentryToken) {
116
+ console.warn(`尚未设置 ${s.red},推送 sourcemap 到 sentry 的功能将无效`);
117
+ }
118
+ }
119
+ if (ignoreSentryToken) {
120
+ envConfig.sentryAuthToken = "";
113
121
  }
114
122
  }
115
123
  return envConfig;
@@ -134,6 +142,10 @@ function htmlInjectPlugin(data) {
134
142
  }
135
143
  function definePageBuildConfig(option) {
136
144
  const {
145
+ notVuePage,
146
+ noPolyfill,
147
+ requireSentryToken,
148
+ ignoreSentryToken,
137
149
  manualChunks,
138
150
  badPackages = [],
139
151
  plugins = [],
@@ -148,7 +160,7 @@ function definePageBuildConfig(option) {
148
160
  return async function({ command, mode }) {
149
161
  var _a, _b, _c;
150
162
  const justBuild = mode === "build";
151
- const envs = getBuildEnv(command, mode, justBuild);
163
+ const envs = getBuildEnv(command, mode, justBuild, requireSentryToken, ignoreSentryToken);
152
164
  const gitInfo = justBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
153
165
  const isProductMode = mode === "production" || mode === "prod";
154
166
  const trunkMap = {
@@ -186,9 +198,9 @@ function definePageBuildConfig(option) {
186
198
  }
187
199
  },
188
200
  plugins: [
189
- vue(),
190
- vueDevTools(),
191
- legacy({
201
+ notVuePage ? null : vue(),
202
+ notVuePage ? null : vueDevTools(),
203
+ noPolyfill ? null : legacy({
192
204
  targets: ["defaults", "> 0.1%", "last 5 versions and not dead"],
193
205
  // https://github.com/vitejs/vite/blob/main/packages/plugin-legacy/src/index.ts#L170
194
206
  // https://unpkg.com/browse/core-js@3.41.0/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/scripts",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "scripts for seayoo web repos",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -25,6 +25,6 @@ interface IBuildEnvs {
25
25
  /**
26
26
  * 获取构建环境配置
27
27
  */
28
- export declare function getBuildEnv(command: "serve" | "build", mode: string, onlyBuild?: boolean): IBuildEnvs;
28
+ export declare function getBuildEnv(command: "serve" | "build", mode: string, onlyBuild?: boolean, requireSentryToken?: boolean, ignoreSentryToken?: boolean): IBuildEnvs;
29
29
  export declare function transformEnvs(envs: Record<string, unknown>): Record<string, string>;
30
30
  export {};
@@ -1,14 +1,24 @@
1
1
  import type { UserConfig, UserConfigFnPromise } from "vite";
2
2
  interface ExternalConfig {
3
+ /** 是否不使用 vue */
4
+ notVuePage?: boolean;
5
+ /** 是否不加载 polyfill */
6
+ noPolyfill?: boolean;
3
7
  /** sentry 配置 */
4
8
  sentry?: {
5
9
  project?: string;
6
10
  url?: string;
7
11
  org?: string;
8
12
  };
13
+ /** 是否强制要求提供 sentryToken */
14
+ requireSentryToken?: boolean;
15
+ /** 是否忽略 sentryToken 设置 */
16
+ ignoreSentryToken?: boolean;
9
17
  /** finder 配置 */
10
18
  finder?: {
11
- /** 是否部署完毕后打开目标文件(index.html)也可以指定不同的目标文件 */
19
+ /**
20
+ * 是否部署完毕后打开目标文件(index.html)也可以指定不同的目标文件
21
+ */
12
22
  preview?: boolean | string | string[];
13
23
  /**
14
24
  * 忽略部署的文件,如果是目录则需要以 / 结尾,支持 * 占位符模糊匹配。
@@ -17,8 +27,6 @@ interface ExternalConfig {
17
27
  */
18
28
  ignoreFiles?: string[];
19
29
  };
20
- /** 仅仅编译 */
21
- onlyBuild?: boolean;
22
30
  /**
23
31
  * 手工指定 trunk 合并策略,Record<key, chunk>,即 id.include(key) 则打到 trunk 中
24
32
  *
@@ -32,7 +40,7 @@ interface ExternalConfig {
32
40
  /**
33
41
  * 指定哪些不够友好的包,这些包的 iife 或修改全局 windows 变量的行为导致默认 tree-shaking 策略失效
34
42
  *
35
- * 从而这些包被误打入最终的产物中,无谓增加了包的体积。默认 `thinkingdata` 和 `@esotericsoftware`
43
+ * 从而这些包被误打入最终的产物中,无谓增加了包的体积。默认 `thinkingdata` 和 `@esotericsoftware/spine`
36
44
  */
37
45
  badPackages?: string[];
38
46
  }