@seayoo-web/scripts 2.5.4 → 2.5.5

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
@@ -152,11 +152,11 @@ function definePageBuildConfig(option) {
152
152
  manualChunks,
153
153
  badPackages = [],
154
154
  plugins = [],
155
- define = {},
156
155
  build = {},
157
156
  resolve = {},
158
157
  server = {},
159
158
  sentry = {},
159
+ base,
160
160
  ...optionReset
161
161
  } = option || {};
162
162
  const { alias, ...resolveReset } = resolve;
@@ -182,8 +182,13 @@ function definePageBuildConfig(option) {
182
182
  if (k) return trunkMap[k];
183
183
  };
184
184
  const ignoreSideEffects = ["thinkingdata", "@esotericsoftware/spine", ...badPackages];
185
+ const baseValue = typeof base === "object" && base ? base[mode] : typeof base === "string" ? base : "./";
186
+ if (baseValue === void 0 && mode !== "development") {
187
+ console.warn(`base 参数在模式(${mode})下未设置内容`.red);
188
+ process.exit(1);
189
+ }
185
190
  return {
186
- base: "./",
191
+ base: baseValue || "./",
187
192
  build: {
188
193
  emptyOutDir: true,
189
194
  outDir: join(process.cwd(), "./dist"),
@@ -232,8 +237,7 @@ function definePageBuildConfig(option) {
232
237
  BUILD_TIME: envs.stamp,
233
238
  BUILD_MODE: envs.mode,
234
239
  BUILD_VERSION: (gitInfo == null ? void 0 : gitInfo.hash) || "",
235
- ...envs.viteEnvs,
236
- ...define
240
+ ...envs.viteEnvs
237
241
  }),
238
242
  ...plugins,
239
243
  command === "build" && envs.deployTo && !justBuild && gitInfo ? viteDeployPlugin({
@@ -262,8 +266,7 @@ function definePageBuildConfig(option) {
262
266
  define: transformEnvs({
263
267
  BUILD_TIME: envs.stamp,
264
268
  BUILD_MODE: envs.mode,
265
- ...envs.viteEnvs,
266
- ...define
269
+ ...envs.viteEnvs
267
270
  }),
268
271
  resolve: {
269
272
  alias: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/scripts",
3
- "version": "2.5.4",
3
+ "version": "2.5.5",
4
4
  "description": "scripts for seayoo web repos",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -1,5 +1,7 @@
1
1
  import type { UserConfig, UserConfigFnPromise } from "vite";
2
2
  interface ExternalConfig {
3
+ /** 设置base路径,支持配置多组 base,以 mode 为key */
4
+ base?: string | Record<string, string>;
3
5
  /** 是否不使用 vue */
4
6
  notVuePage?: boolean;
5
7
  /** 是否不加载 polyfill */
@@ -47,5 +49,5 @@ interface ExternalConfig {
47
49
  /**
48
50
  * 导出一个动态的配置工厂函数
49
51
  */
50
- export declare function definePageBuildConfig(option?: UserConfig & ExternalConfig): UserConfigFnPromise;
52
+ export declare function definePageBuildConfig(option?: Omit<UserConfig, "base" | "define"> & ExternalConfig): UserConfigFnPromise;
51
53
  export {};