@pubinfo/vite 2.0.15 → 2.1.1
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.d.ts +1 -20
- package/dist/index.js +11 -343
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -6,21 +6,6 @@ import { Options } from "@pubinfo/unplugin-openapi";
|
|
|
6
6
|
export * from "rolldown-vite";
|
|
7
7
|
export * from "vite-plugin-fake-server/client";
|
|
8
8
|
|
|
9
|
-
//#region src/plugins/built-in/chrome-devtools.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Chrome DevTools 插件配置选项
|
|
12
|
-
*/
|
|
13
|
-
interface ChromeDevtoolsOptions {
|
|
14
|
-
/** 是否启用插件 */
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
/** 自定义端口,如果不指定则自动分配 */
|
|
17
|
-
port?: number;
|
|
18
|
-
/** 是否自动注入调试脚本到页面 */
|
|
19
|
-
autoInject?: boolean;
|
|
20
|
-
/** DevTools 面板访问路径 */
|
|
21
|
-
panelPath?: string;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
9
|
//#region src/plugins/built-in/inject-auto.d.ts
|
|
25
10
|
interface InjectAutoOptions {
|
|
26
11
|
id: string;
|
|
@@ -75,8 +60,6 @@ interface PubinfoConfig {
|
|
|
75
60
|
devtools?: Omit<VitePluginVueDevToolsOptions, 'enabled'> & {
|
|
76
61
|
enabled?: boolean;
|
|
77
62
|
};
|
|
78
|
-
/** chrome devtools */
|
|
79
|
-
chromeDevtools?: ChromeDevtoolsOptions;
|
|
80
63
|
/** `commitlint` */
|
|
81
64
|
commitlint?: boolean | CommitlintOptions;
|
|
82
65
|
}
|
|
@@ -98,7 +81,6 @@ declare function definePubinfoConfig(config: PubinfoConfig): {
|
|
|
98
81
|
devtools?: Omit<vite_plugin_vue_devtools0.VitePluginVueDevToolsOptions, "enabled"> & {
|
|
99
82
|
enabled?: boolean;
|
|
100
83
|
};
|
|
101
|
-
chromeDevtools?: ChromeDevtoolsOptions;
|
|
102
84
|
commitlint?: boolean | CommitlintOptions;
|
|
103
85
|
};
|
|
104
86
|
/**
|
|
@@ -112,8 +94,7 @@ declare function defineModuleConfig(config: ModuleConfig): {
|
|
|
112
94
|
devtools?: Omit<vite_plugin_vue_devtools0.VitePluginVueDevToolsOptions, "enabled"> & {
|
|
113
95
|
enabled?: boolean;
|
|
114
96
|
};
|
|
115
|
-
chromeDevtools?: ChromeDevtoolsOptions;
|
|
116
97
|
commitlint?: boolean | CommitlintOptions;
|
|
117
98
|
};
|
|
118
99
|
//#endregion
|
|
119
|
-
export {
|
|
100
|
+
export { CommitlintOptions, ModuleConfig, PubinfoConfig, ResolverPluginOptions, defineModuleConfig, definePubinfoConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { defineConfig, loadEnv, mergeConfig, normalizePath } from "rolldown-vite";
|
|
3
3
|
import process, { cwd } from "node:process";
|
|
4
|
+
import { logger } from "@pubinfo/shared";
|
|
4
5
|
import chalk from "chalk";
|
|
5
|
-
import consola from "consola";
|
|
6
6
|
import path, { dirname, join, posix, relative, resolve } from "node:path";
|
|
7
7
|
import vue from "@vitejs/plugin-vue";
|
|
8
8
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
@@ -27,6 +27,7 @@ import IconsResolver from "unplugin-icons/resolver";
|
|
|
27
27
|
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
|
|
28
28
|
import components from "unplugin-vue-components/vite";
|
|
29
29
|
import compression from "vite-plugin-compression";
|
|
30
|
+
import { pubinfoDevtools } from "@pubinfo/devtools";
|
|
30
31
|
import dts from "vite-plugin-dts";
|
|
31
32
|
import Icons from "unplugin-icons/vite";
|
|
32
33
|
import { libInjectCss } from "vite-plugin-lib-inject-css";
|
|
@@ -65,7 +66,7 @@ function getServerProxy(env, isProxy) {
|
|
|
65
66
|
const url = env[envKey];
|
|
66
67
|
const { pathname } = new URL(url);
|
|
67
68
|
const pk = `${pathname}/proxy`;
|
|
68
|
-
if (pk in serverProxy)
|
|
69
|
+
if (pk in serverProxy) logger.warn(`The env key ${chalk.bold.yellowBright(envKey)} ➜ ${chalk.bold.green(url)} already exists`);
|
|
69
70
|
else serverProxy[pk] = {
|
|
70
71
|
target: url,
|
|
71
72
|
changeOrigin: true,
|
|
@@ -76,345 +77,6 @@ function getServerProxy(env, isProxy) {
|
|
|
76
77
|
return serverProxy;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/plugins/built-in/chrome-devtools.ts
|
|
81
|
-
const GLOBAL_STATE_KEY = "__pubinfoChromeDevtoolsState__";
|
|
82
|
-
const DEFAULT_VITE_PORT = 5173;
|
|
83
|
-
const DEFAULT_HOST = "localhost";
|
|
84
|
-
const RANDOM_PORT_RANGE = {
|
|
85
|
-
min: 56e3,
|
|
86
|
-
max: 64e3
|
|
87
|
-
};
|
|
88
|
-
function getGlobalState() {
|
|
89
|
-
const globalRef = globalThis;
|
|
90
|
-
if (!globalRef[GLOBAL_STATE_KEY]) globalRef[GLOBAL_STATE_KEY] = {};
|
|
91
|
-
return globalRef[GLOBAL_STATE_KEY];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 管理 chii (Chrome DevTools 后端) 的生命周期与日志。
|
|
95
|
-
*/
|
|
96
|
-
var ChiiServiceManager = class {
|
|
97
|
-
port;
|
|
98
|
-
isStarted = false;
|
|
99
|
-
loggingPatched = false;
|
|
100
|
-
globalState;
|
|
101
|
-
constructor() {
|
|
102
|
-
this.globalState = getGlobalState();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* 启动 chii 服务,自动处理端口复用、冲突检测与启动失败兜底。
|
|
106
|
-
*/
|
|
107
|
-
async start(customPort, vitePort, viteHost, panelPath) {
|
|
108
|
-
if (this.isStarted && this.port) return this.port;
|
|
109
|
-
const reusedPort = await this.tryReuseExistingService(customPort, vitePort);
|
|
110
|
-
if (reusedPort) {
|
|
111
|
-
this.registerPort(reusedPort);
|
|
112
|
-
return reusedPort;
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
const { start } = await this.importChii();
|
|
116
|
-
const portCandidate = customPort || this.generatePort(vitePort);
|
|
117
|
-
const port = await this.findAvailablePort(portCandidate, customPort === void 0);
|
|
118
|
-
if (port == null) {
|
|
119
|
-
console.warn("[pubinfo][chrome-devtools] 未找到可用的 DevTools 端口,跳过启动");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
start({ port });
|
|
123
|
-
this.registerPort(port);
|
|
124
|
-
return port;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.warn("[pubinfo][chrome-devtools] 启动 Chii 失败:", error);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
getPort() {
|
|
131
|
-
return this.port;
|
|
132
|
-
}
|
|
133
|
-
isServiceStarted() {
|
|
134
|
-
return this.isStarted && !!this.port;
|
|
135
|
-
}
|
|
136
|
-
registerPort(port) {
|
|
137
|
-
this.port = port;
|
|
138
|
-
this.isStarted = true;
|
|
139
|
-
this.globalState.port = port;
|
|
140
|
-
}
|
|
141
|
-
async tryReuseExistingService(customPort, vitePort) {
|
|
142
|
-
if (this.globalState.port != null) {
|
|
143
|
-
if (await this.isChiiRunning(this.globalState.port)) return this.globalState.port;
|
|
144
|
-
this.globalState.port = void 0;
|
|
145
|
-
}
|
|
146
|
-
if (customPort != null) {
|
|
147
|
-
if (await this.isChiiRunning(customPort)) return customPort;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (vitePort) {
|
|
151
|
-
const generatedPort = this.generatePort(vitePort);
|
|
152
|
-
if (await this.isChiiRunning(generatedPort)) return generatedPort;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
generatePort(vitePort) {
|
|
156
|
-
if (vitePort) {
|
|
157
|
-
const prefixedCandidate = Number(`6${vitePort}`);
|
|
158
|
-
if (Number.isFinite(prefixedCandidate) && prefixedCandidate <= 65535) return prefixedCandidate;
|
|
159
|
-
const highRangeCandidate = 6e4 + vitePort % 1e3;
|
|
160
|
-
if (highRangeCandidate <= 65535) return highRangeCandidate;
|
|
161
|
-
}
|
|
162
|
-
const { min, max } = RANDOM_PORT_RANGE;
|
|
163
|
-
return min + Math.floor(Math.random() * (max - min + 1));
|
|
164
|
-
}
|
|
165
|
-
async findAvailablePort(startPort, allowIncrement) {
|
|
166
|
-
let port = startPort;
|
|
167
|
-
for (let attempt = 0; attempt < 20; attempt += 1) {
|
|
168
|
-
if (await this.isPortAvailable(port)) return port;
|
|
169
|
-
if (!allowIncrement) return;
|
|
170
|
-
port += 1;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
async isPortAvailable(port) {
|
|
174
|
-
const net = await this.importNet();
|
|
175
|
-
return await new Promise((resolve$1) => {
|
|
176
|
-
const tester = net.createServer();
|
|
177
|
-
tester.once("error", () => {
|
|
178
|
-
try {
|
|
179
|
-
tester.close();
|
|
180
|
-
} catch {}
|
|
181
|
-
resolve$1(false);
|
|
182
|
-
});
|
|
183
|
-
tester.once("listening", () => {
|
|
184
|
-
tester.close(() => resolve$1(true));
|
|
185
|
-
});
|
|
186
|
-
tester.listen(port);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
async isChiiRunning(port) {
|
|
190
|
-
try {
|
|
191
|
-
const controller = new AbortController();
|
|
192
|
-
const timeout = setTimeout(() => controller.abort(), 300);
|
|
193
|
-
try {
|
|
194
|
-
const response = await fetch(`http://127.0.0.1:${port}/targets`, { signal: controller.signal });
|
|
195
|
-
if (!response.ok) return false;
|
|
196
|
-
const data = await response.json();
|
|
197
|
-
return Array.isArray(data?.targets);
|
|
198
|
-
} finally {
|
|
199
|
-
clearTimeout(timeout);
|
|
200
|
-
}
|
|
201
|
-
} catch {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async importChii() {
|
|
206
|
-
await this.patchChiiLogger();
|
|
207
|
-
return await import(
|
|
208
|
-
/* @vite-ignore */
|
|
209
|
-
"chii"
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
async importNet() {
|
|
213
|
-
return await import("node:net");
|
|
214
|
-
}
|
|
215
|
-
async patchChiiLogger() {
|
|
216
|
-
if (this.loggingPatched) return;
|
|
217
|
-
try {
|
|
218
|
-
const utilModule = createRequire(import.meta.url)("chii/server/lib/util.js");
|
|
219
|
-
const utilTarget = typeof utilModule.log === "function" ? utilModule : utilModule.default;
|
|
220
|
-
if (!utilTarget || typeof utilTarget.log !== "function") {
|
|
221
|
-
console.warn("[pubinfo][chrome-devtools] 未检测到 chii util.log,跳过日志定制");
|
|
222
|
-
this.loggingPatched = true;
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const descriptor = Object.getOwnPropertyDescriptor(utilTarget, "log");
|
|
226
|
-
if (descriptor && descriptor.writable === false) Object.defineProperty(utilTarget, "log", {
|
|
227
|
-
...descriptor,
|
|
228
|
-
writable: true,
|
|
229
|
-
configurable: true
|
|
230
|
-
});
|
|
231
|
-
const patchedLog = () => {};
|
|
232
|
-
const targetExports = utilTarget;
|
|
233
|
-
const moduleExports = utilModule;
|
|
234
|
-
const defaultExports = utilModule.default;
|
|
235
|
-
targetExports.log = patchedLog;
|
|
236
|
-
if (moduleExports !== targetExports) moduleExports.log = patchedLog;
|
|
237
|
-
if (defaultExports && defaultExports !== targetExports) defaultExports.log = patchedLog;
|
|
238
|
-
this.loggingPatched = true;
|
|
239
|
-
} catch (error) {
|
|
240
|
-
console.warn("[pubinfo][chrome-devtools] 自定义 DevTools 日志失败:", error);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* 处理 /__chrome_devtools 面板访问跳转:实时查询 chii targets,生成前端面板地址。
|
|
246
|
-
*/
|
|
247
|
-
var DevToolsPanelHandler = class {
|
|
248
|
-
panelPath;
|
|
249
|
-
serviceManager;
|
|
250
|
-
constructor(panelPath, serviceManager) {
|
|
251
|
-
this.panelPath = panelPath;
|
|
252
|
-
this.serviceManager = serviceManager;
|
|
253
|
-
}
|
|
254
|
-
createMiddleware(server) {
|
|
255
|
-
server.middlewares.use(async (req, res, next) => {
|
|
256
|
-
if (!this.isTargetPath(req.url)) return next();
|
|
257
|
-
const port = this.serviceManager.getPort();
|
|
258
|
-
if (!port) {
|
|
259
|
-
this.sendErrorResponse(res, "DevTools 后端服务未启动");
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
try {
|
|
263
|
-
const devtoolsUrl = await this.getDevToolsUrl(port);
|
|
264
|
-
this.sendRedirectResponse(res, devtoolsUrl);
|
|
265
|
-
} catch (error) {
|
|
266
|
-
console.warn("[pubinfo][chrome-devtools] 获取 DevTools URL 失败:", error);
|
|
267
|
-
this.sendRedirectResponse(res, `http://127.0.0.1:${port}/`);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
isTargetPath(url) {
|
|
272
|
-
if (!url) return false;
|
|
273
|
-
return url === this.panelPath || url === `${this.panelPath}/`;
|
|
274
|
-
}
|
|
275
|
-
async getDevToolsUrl(port) {
|
|
276
|
-
const firstTarget = (await (await fetch(`http://127.0.0.1:${port}/targets`)).json())?.targets?.[0];
|
|
277
|
-
if (firstTarget) {
|
|
278
|
-
const wsId = Math.random().toString(36).slice(2, 10);
|
|
279
|
-
return `http://127.0.0.1:${port}/front_end/chii_app.html?ws=${encodeURIComponent(`127.0.0.1:${port}/client/${wsId}?target=${firstTarget.id}`)}&rtc=false`;
|
|
280
|
-
}
|
|
281
|
-
return `http://127.0.0.1:${port}/`;
|
|
282
|
-
}
|
|
283
|
-
sendErrorResponse(res, message) {
|
|
284
|
-
res.statusCode = 503;
|
|
285
|
-
res.end(message);
|
|
286
|
-
}
|
|
287
|
-
sendRedirectResponse(res, location) {
|
|
288
|
-
res.statusCode = 302;
|
|
289
|
-
res.setHeader("Location", location);
|
|
290
|
-
res.end();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* 负责把 target.js 注入到 HTML 中,使页面成为可调试目标。
|
|
295
|
-
*/
|
|
296
|
-
var HtmlInjector = class {
|
|
297
|
-
serviceManager;
|
|
298
|
-
constructor(serviceManager) {
|
|
299
|
-
this.serviceManager = serviceManager;
|
|
300
|
-
}
|
|
301
|
-
injectScript(html) {
|
|
302
|
-
const port = this.serviceManager.getPort();
|
|
303
|
-
if (!port) return html;
|
|
304
|
-
const injectedMarker = `//__chrome_devtools_target_${port}`;
|
|
305
|
-
if (html.includes(injectedMarker)) return html;
|
|
306
|
-
const scriptTag = this.createScriptTag(port, injectedMarker);
|
|
307
|
-
return this.insertScriptTag(html, scriptTag);
|
|
308
|
-
}
|
|
309
|
-
createScriptTag(port, marker) {
|
|
310
|
-
return `<script>${marker}<\/script>\n<script src="http://127.0.0.1:${port}/target.js" data-pubinfo-devtools="chrome"><\/script>`;
|
|
311
|
-
}
|
|
312
|
-
insertScriptTag(html, scriptTag) {
|
|
313
|
-
if (/<head[\s\S]*?>/i.test(html)) return html.replace(/<head([\s\S]*?)>/i, (match) => `${match}\n${scriptTag}`);
|
|
314
|
-
return html.replace(/<body(.*?)>/i, (match) => `${match}\n${scriptTag}`);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* 管理 Vite Dev Server 与 chii 服务之间的协作:监听端口、控制打印、确保服务可用。
|
|
319
|
-
*/
|
|
320
|
-
var DevServerOrchestrator = class {
|
|
321
|
-
server;
|
|
322
|
-
lastResolvedServerInfo;
|
|
323
|
-
constructor(serviceManager, panelHandler, panelPath, customPort) {
|
|
324
|
-
this.serviceManager = serviceManager;
|
|
325
|
-
this.panelHandler = panelHandler;
|
|
326
|
-
this.panelPath = panelPath;
|
|
327
|
-
this.customPort = customPort;
|
|
328
|
-
}
|
|
329
|
-
attach(server) {
|
|
330
|
-
this.server = server;
|
|
331
|
-
this.lastResolvedServerInfo = this.resolveServerInfo();
|
|
332
|
-
this.panelHandler.createMiddleware(server);
|
|
333
|
-
this.bindStartupHooks(server);
|
|
334
|
-
}
|
|
335
|
-
async ensureReady() {
|
|
336
|
-
const info = this.resolveServerInfo();
|
|
337
|
-
await this.serviceManager.start(this.customPort, info.port, info.host, this.panelPath);
|
|
338
|
-
}
|
|
339
|
-
async ensureReadyIfNeeded() {
|
|
340
|
-
if (!this.serviceManager.isServiceStarted()) await this.ensureReady();
|
|
341
|
-
}
|
|
342
|
-
bindStartupHooks(server) {
|
|
343
|
-
const scheduleStart = () => {
|
|
344
|
-
(async () => {
|
|
345
|
-
await this.ensureReady();
|
|
346
|
-
})();
|
|
347
|
-
};
|
|
348
|
-
if (server.httpServer?.listening) scheduleStart();
|
|
349
|
-
else server.httpServer?.once("listening", () => {
|
|
350
|
-
this.lastResolvedServerInfo = void 0;
|
|
351
|
-
scheduleStart();
|
|
352
|
-
});
|
|
353
|
-
const originalPrintUrls = server.printUrls;
|
|
354
|
-
server.printUrls = () => {
|
|
355
|
-
originalPrintUrls();
|
|
356
|
-
(async () => {
|
|
357
|
-
await this.ensureReady();
|
|
358
|
-
})();
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
resolveServerInfo() {
|
|
362
|
-
const info = this.computeServerInfo();
|
|
363
|
-
this.lastResolvedServerInfo = info;
|
|
364
|
-
return info;
|
|
365
|
-
}
|
|
366
|
-
computeServerInfo() {
|
|
367
|
-
const server = this.server;
|
|
368
|
-
if (!server) return {
|
|
369
|
-
host: DEFAULT_HOST,
|
|
370
|
-
port: DEFAULT_VITE_PORT
|
|
371
|
-
};
|
|
372
|
-
const localUrl = server.resolvedUrls?.local?.[0];
|
|
373
|
-
if (localUrl) try {
|
|
374
|
-
const url = new URL(localUrl);
|
|
375
|
-
if (url.hostname && url.port) return {
|
|
376
|
-
host: this.normalizeHost(url.hostname),
|
|
377
|
-
port: Number(url.port) || DEFAULT_VITE_PORT
|
|
378
|
-
};
|
|
379
|
-
} catch {}
|
|
380
|
-
const configuredHost = typeof server.config.server.host === "string" ? server.config.server.host : DEFAULT_HOST;
|
|
381
|
-
const address = server.httpServer?.address();
|
|
382
|
-
if (address && typeof address === "object" && "port" in address && typeof address.port === "number") return {
|
|
383
|
-
host: this.normalizeHost(configuredHost),
|
|
384
|
-
port: address.port
|
|
385
|
-
};
|
|
386
|
-
return {
|
|
387
|
-
host: this.normalizeHost(configuredHost),
|
|
388
|
-
port: server.config.server.port || DEFAULT_VITE_PORT
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
normalizeHost(host) {
|
|
392
|
-
if (!host || host === "0.0.0.0" || host === "::") return DEFAULT_HOST;
|
|
393
|
-
return host;
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
function createChromeDevtools(options = {}) {
|
|
397
|
-
const { enabled = true, port, autoInject = true, panelPath = "/__chrome_devtools" } = options;
|
|
398
|
-
if (!enabled) return null;
|
|
399
|
-
const serviceManager = new ChiiServiceManager();
|
|
400
|
-
const panelHandler = new DevToolsPanelHandler(panelPath, serviceManager);
|
|
401
|
-
const htmlInjector = new HtmlInjector(serviceManager);
|
|
402
|
-
const orchestrator = new DevServerOrchestrator(serviceManager, panelHandler, panelPath, port);
|
|
403
|
-
return {
|
|
404
|
-
name: "pubinfo:chrome-devtools",
|
|
405
|
-
apply: "serve",
|
|
406
|
-
enforce: "post",
|
|
407
|
-
async configureServer(server) {
|
|
408
|
-
orchestrator.attach(server);
|
|
409
|
-
},
|
|
410
|
-
async transformIndexHtml(html) {
|
|
411
|
-
if (!autoInject) return html;
|
|
412
|
-
await orchestrator.ensureReadyIfNeeded();
|
|
413
|
-
return htmlInjector.injectScript(html);
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
80
|
//#endregion
|
|
419
81
|
//#region src/plugins/built-in/clean-build.ts
|
|
420
82
|
function createCleanBuild() {
|
|
@@ -436,7 +98,7 @@ function createCleanBuild() {
|
|
|
436
98
|
force: true
|
|
437
99
|
});
|
|
438
100
|
} catch (error) {
|
|
439
|
-
|
|
101
|
+
logger.error(`[vite-plugin-clean-build] Failed to clean build directory: ${error}`);
|
|
440
102
|
}
|
|
441
103
|
}
|
|
442
104
|
};
|
|
@@ -858,6 +520,12 @@ function createCompression(env) {
|
|
|
858
520
|
return plugin;
|
|
859
521
|
}
|
|
860
522
|
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/plugins/intergrations/devtools.ts
|
|
525
|
+
function createPubinfoDevtoolsPlugin() {
|
|
526
|
+
return pubinfoDevtools();
|
|
527
|
+
}
|
|
528
|
+
|
|
861
529
|
//#endregion
|
|
862
530
|
//#region src/plugins/intergrations/dts.ts
|
|
863
531
|
function createDTS() {
|
|
@@ -934,7 +602,7 @@ function createVitePlugins(viteEnv, isBuild = false, config, type) {
|
|
|
934
602
|
createIcons(),
|
|
935
603
|
createMock(viteEnv, isBuild),
|
|
936
604
|
createInspector(config.devtools),
|
|
937
|
-
|
|
605
|
+
createPubinfoDevtoolsPlugin(),
|
|
938
606
|
createOpenAPI(config.openapi),
|
|
939
607
|
createLibResolver(config.resolver),
|
|
940
608
|
createAppInfo(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
"abort-controller": "^3.0.0",
|
|
29
29
|
"boxen": "^8.0.1",
|
|
30
30
|
"chalk": "^5.4.1",
|
|
31
|
-
"chii": "^1.15.5",
|
|
32
|
-
"consola": "^3.4.2",
|
|
33
31
|
"dayjs": "^1.11.13",
|
|
34
32
|
"fast-glob": "^3.3.3",
|
|
35
33
|
"fs-extra": "^11.3.0",
|
|
@@ -50,7 +48,9 @@
|
|
|
50
48
|
"vite-plugin-env-runtime": "^0.3.6",
|
|
51
49
|
"vite-plugin-fake-server": "^2.2.0",
|
|
52
50
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
53
|
-
"vite-plugin-vue-devtools": "^8.0.0"
|
|
51
|
+
"vite-plugin-vue-devtools": "^8.0.0",
|
|
52
|
+
"@pubinfo/devtools": "2.1.1",
|
|
53
|
+
"@pubinfo/shared": "2.1.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
"@types/micromatch": "^4.0.9",
|
|
59
59
|
"@types/node": "^24.0.10",
|
|
60
60
|
"@types/picomatch": "^4.0.2",
|
|
61
|
-
"vue": "^3.5.17"
|
|
62
|
-
"@pubinfo/shared": "2.0.15"
|
|
61
|
+
"vue": "^3.5.17"
|
|
63
62
|
},
|
|
64
63
|
"scripts": {
|
|
65
64
|
"dev": "tsdown --watch",
|