@seayoo-web/scripts 2.0.4 → 2.0.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
@@ -130,6 +130,8 @@ function htmlInjectPlugin(data) {
130
130
  }
131
131
  function definePageBuildConfig(option) {
132
132
  const {
133
+ onlyBuild,
134
+ manualChunks,
133
135
  plugins = [],
134
136
  define = {},
135
137
  build = {},
@@ -140,9 +142,16 @@ function definePageBuildConfig(option) {
140
142
  } = option || {};
141
143
  const { alias, ...resolveReset } = resolve;
142
144
  return async function({ command, mode }) {
145
+ var _a;
143
146
  const envs = getBuildEnv(command, mode);
144
- const gitInfo = await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
147
+ const gitInfo = onlyBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
145
148
  const isProductMode = mode === "production" || mode === "prod";
149
+ const trunkMap = manualChunks || { "naive-ui": "naive-ui", node_modules: "vendor" };
150
+ const trunkKeys = Object.keys(trunkMap);
151
+ const trunkFn = function(id) {
152
+ const k = trunkKeys.find((k2) => id.includes(k2));
153
+ if (k) return trunkMap[k];
154
+ };
146
155
  return {
147
156
  base: "./",
148
157
  build: {
@@ -151,7 +160,14 @@ function definePageBuildConfig(option) {
151
160
  assetsDir: "assets",
152
161
  reportCompressedSize: false,
153
162
  sourcemap: command === "build" && !!envs.sentryAuthToken,
154
- ...build
163
+ ...build,
164
+ rollupOptions: {
165
+ output: {
166
+ manualChunks: trunkFn,
167
+ ...(_a = build.rollupOptions) == null ? void 0 : _a.output
168
+ },
169
+ ...build.rollupOptions
170
+ }
155
171
  },
156
172
  plugins: [
157
173
  vue(),
@@ -180,12 +196,12 @@ function definePageBuildConfig(option) {
180
196
  htmlInjectPlugin({
181
197
  BUILD_TIME: envs.stamp,
182
198
  BUILD_MODE: envs.mode,
183
- BUILD_VERSION: gitInfo.hash,
199
+ BUILD_VERSION: (gitInfo == null ? void 0 : gitInfo.hash) || "",
184
200
  ...envs.viteEnvs,
185
201
  ...define
186
202
  }),
187
203
  ...plugins,
188
- command === "build" && envs.deployTo ? viteDeployPlugin({
204
+ command === "build" && envs.deployTo && !onlyBuild && gitInfo ? viteDeployPlugin({
189
205
  deployTo: envs.deployTo,
190
206
  user: envs.deployUser,
191
207
  key: envs.deployKey,
@@ -197,7 +213,7 @@ function definePageBuildConfig(option) {
197
213
  }
198
214
  }
199
215
  }) : null,
200
- command === "build" && envs.sentryAuthToken ? sentryVitePlugin({
216
+ command === "build" && envs.sentryAuthToken && !onlyBuild ? sentryVitePlugin({
201
217
  authToken: envs.sentryAuthToken,
202
218
  org: "sentry",
203
219
  url: sentry.url || "https://sentry.seayoo.com/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/scripts",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "scripts for seayoo web repos",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -5,6 +5,16 @@ interface ExternalConfig {
5
5
  project?: string;
6
6
  url?: string;
7
7
  };
8
+ /** 仅仅编译 */
9
+ onlyBuild?: boolean;
10
+ /**
11
+ * 手工指定 trunk 合并策略,Record<key, chunk>,即 id.include(key) 则打到 trunk 中
12
+ *
13
+ * 默认 { "naive-ui": "naive-ui", "node_modules": "vendor" }
14
+ *
15
+ * 也可以手工设定 build.rollupOptions.output.manualChunks 来自定义
16
+ */
17
+ manualChunks?: Record<string, string>;
8
18
  }
9
19
  /**
10
20
  * 导出一个动态的配置工厂函数