@pubinfo/vite 2.0.0-rc.4 → 2.0.0-rc.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.d.ts +18 -3
- package/dist/index.js +254 -150
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,15 @@ import { Options } from "@pubinfo/unplugin-openapi";
|
|
|
4
4
|
export * from "rolldown-vite";
|
|
5
5
|
export * from "vite-plugin-fake-server/client";
|
|
6
6
|
|
|
7
|
-
//#region src/plugins/
|
|
7
|
+
//#region src/plugins/built-in/inject-auto.d.ts
|
|
8
|
+
interface InjectAutoOptions {
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 自动注入代码
|
|
13
|
+
*/
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/plugins/built-in/lib-resolver.d.ts
|
|
8
16
|
type GlobInput = string;
|
|
9
17
|
interface ModuleEntries {
|
|
10
18
|
/**
|
|
@@ -37,6 +45,12 @@ interface PubinfoConfig {
|
|
|
37
45
|
/** `resolver` */
|
|
38
46
|
resolver?: ResolverPluginOptions;
|
|
39
47
|
}
|
|
48
|
+
interface ModuleConfig extends PubinfoConfig {
|
|
49
|
+
/**
|
|
50
|
+
* `moduleId`
|
|
51
|
+
*/
|
|
52
|
+
moduleId: InjectAutoOptions['id'];
|
|
53
|
+
}
|
|
40
54
|
//#endregion
|
|
41
55
|
//#region src/config/index.d.ts
|
|
42
56
|
/**
|
|
@@ -50,10 +64,11 @@ declare function definePubinfoConfig(config: PubinfoConfig): {
|
|
|
50
64
|
/**
|
|
51
65
|
* 构建模块配置
|
|
52
66
|
*/
|
|
53
|
-
declare function defineModuleConfig(config:
|
|
67
|
+
declare function defineModuleConfig(config: ModuleConfig): {
|
|
54
68
|
vite: UserConfigFnObject;
|
|
69
|
+
moduleId: InjectAutoOptions["id"];
|
|
55
70
|
openapi?: _pubinfo_unplugin_openapi0.Options;
|
|
56
71
|
resolver?: ResolverPluginOptions;
|
|
57
72
|
};
|
|
58
73
|
//#endregion
|
|
59
|
-
export { PubinfoConfig, ResolverPluginOptions, defineModuleConfig, definePubinfoConfig };
|
|
74
|
+
export { ModuleConfig, PubinfoConfig, ResolverPluginOptions, defineModuleConfig, definePubinfoConfig };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,18 @@ import consola from "consola";
|
|
|
6
6
|
import { 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";
|
|
9
|
+
import boxen from "boxen";
|
|
10
|
+
import fg from "fast-glob";
|
|
11
|
+
import { merge } from "lodash-es";
|
|
12
|
+
import picomatch from "picomatch";
|
|
13
|
+
import dayjs from "dayjs";
|
|
14
|
+
import { readPackageJSON } from "pkg-types";
|
|
15
|
+
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { readFile } from "node:fs/promises";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { Buffer } from "node:buffer";
|
|
19
|
+
import fse from "fs-extra/esm";
|
|
20
|
+
import JSZip from "jszip";
|
|
9
21
|
import autoImport from "unplugin-auto-import/vite";
|
|
10
22
|
import IconsResolver from "unplugin-icons/resolver";
|
|
11
23
|
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
|
|
@@ -13,19 +25,12 @@ import components from "unplugin-vue-components/vite";
|
|
|
13
25
|
import compression from "vite-plugin-compression";
|
|
14
26
|
import dts from "vite-plugin-dts";
|
|
15
27
|
import Icons from "unplugin-icons/vite";
|
|
16
|
-
import boxen from "boxen";
|
|
17
28
|
import { libInjectCss } from "vite-plugin-lib-inject-css";
|
|
18
29
|
import VueDevTools from "vite-plugin-vue-devtools";
|
|
19
30
|
import vueLegacy from "@vitejs/plugin-legacy";
|
|
20
|
-
import fg from "fast-glob";
|
|
21
|
-
import { merge } from "lodash-es";
|
|
22
|
-
import picomatch from "picomatch";
|
|
23
|
-
import { existsSync } from "node:fs";
|
|
24
31
|
import { vitePluginFakeServer } from "vite-plugin-fake-server";
|
|
25
32
|
import OpenAPI from "@pubinfo/unplugin-openapi/vite";
|
|
26
33
|
import Unocss from "unocss/vite";
|
|
27
|
-
import { readFile } from "node:fs/promises";
|
|
28
|
-
import { fileURLToPath } from "node:url";
|
|
29
34
|
|
|
30
35
|
export * from "rolldown-vite"
|
|
31
36
|
|
|
@@ -68,105 +73,15 @@ function getServerProxy(env, isProxy) {
|
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
//#endregion
|
|
71
|
-
//#region src/plugins/
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
...autoImport({
|
|
75
|
-
imports: [
|
|
76
|
-
"vue",
|
|
77
|
-
"vue-router",
|
|
78
|
-
"pinia",
|
|
79
|
-
{ pubinfo: ["useAuth"] }
|
|
80
|
-
],
|
|
81
|
-
ignore: ["h"],
|
|
82
|
-
dts: "./.pubinfo/auto-imports.d.ts",
|
|
83
|
-
resolvers: [AntDesignVueResolver(), IconsResolver({ prefix: "i" })]
|
|
84
|
-
}),
|
|
85
|
-
enforce: "pre"
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/plugins/components.ts
|
|
91
|
-
function createComponents() {
|
|
92
|
-
return components({
|
|
93
|
-
dirs: ["src/components"],
|
|
94
|
-
directives: true,
|
|
95
|
-
include: [
|
|
96
|
-
/\.vue$/,
|
|
97
|
-
/\.vue\?vue/,
|
|
98
|
-
/\.tsx$/
|
|
99
|
-
],
|
|
100
|
-
resolvers: [
|
|
101
|
-
IconsResolver(),
|
|
102
|
-
AntDesignVueResolver({
|
|
103
|
-
resolveIcons: true,
|
|
104
|
-
importStyle: false
|
|
105
|
-
}),
|
|
106
|
-
{
|
|
107
|
-
type: "component",
|
|
108
|
-
resolve(name) {
|
|
109
|
-
if ([
|
|
110
|
-
"PubinfoApp",
|
|
111
|
-
"PubinfoProvider",
|
|
112
|
-
"PubinfoIcon"
|
|
113
|
-
].includes(name)) return {
|
|
114
|
-
name,
|
|
115
|
-
from: "pubinfo"
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
],
|
|
120
|
-
dts: "./.pubinfo/components.d.ts"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/plugins/compression.ts
|
|
126
|
-
function createCompression(env) {
|
|
127
|
-
const { VITE_BUILD_COMPRESS } = env;
|
|
128
|
-
const compressList = VITE_BUILD_COMPRESS?.split(",") ?? [];
|
|
129
|
-
const plugin = [];
|
|
130
|
-
if (compressList.includes("gzip")) plugin.push(compression({
|
|
131
|
-
ext: ".gz",
|
|
132
|
-
deleteOriginFile: false
|
|
133
|
-
}));
|
|
134
|
-
if (compressList.includes("brotli")) plugin.push(compression({
|
|
135
|
-
ext: ".br",
|
|
136
|
-
algorithm: "brotliCompress",
|
|
137
|
-
deleteOriginFile: false
|
|
138
|
-
}));
|
|
139
|
-
return plugin;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
//#endregion
|
|
143
|
-
//#region src/plugins/dts.ts
|
|
144
|
-
function createDTS() {
|
|
145
|
-
return {
|
|
146
|
-
...dts({
|
|
147
|
-
clearPureImport: false,
|
|
148
|
-
exclude: ["tests/**/*"]
|
|
149
|
-
}),
|
|
150
|
-
enforce: "post"
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/plugins/icon.ts
|
|
156
|
-
function createIcons() {
|
|
157
|
-
return Icons({ autoInstall: false });
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/plugins/info.ts
|
|
162
|
-
var Ctx = class {
|
|
76
|
+
//#region src/plugins/built-in/info.ts
|
|
77
|
+
var Ctx$1 = class {
|
|
163
78
|
options;
|
|
164
79
|
setOptions(options) {
|
|
165
80
|
this.options = options;
|
|
166
81
|
}
|
|
167
82
|
async createInfo() {
|
|
168
83
|
console.log(boxen(`\
|
|
169
|
-
欢迎使用${chalk.bold.greenBright("
|
|
84
|
+
欢迎使用${chalk.bold.greenBright(" 产数研发底座系统 ")}\n
|
|
170
85
|
${chalk.green("使用文档地址")} ${chalk.green("➜")} https://134.108.39.195:9090/docs`, {
|
|
171
86
|
padding: 1,
|
|
172
87
|
margin: 1,
|
|
@@ -176,18 +91,18 @@ ${chalk.green("使用文档地址")} ${chalk.green("➜")} https://134.108.39.19
|
|
|
176
91
|
}));
|
|
177
92
|
}
|
|
178
93
|
};
|
|
179
|
-
const ctx = new Ctx();
|
|
180
|
-
function
|
|
94
|
+
const ctx$1 = new Ctx$1();
|
|
95
|
+
function createAppInfo() {
|
|
181
96
|
return {
|
|
182
|
-
name: "
|
|
97
|
+
name: "createAppInfo",
|
|
183
98
|
apply: "serve",
|
|
184
99
|
enforce: "pre",
|
|
185
100
|
configResolved(configuration) {
|
|
186
101
|
const root = configuration.root;
|
|
187
|
-
ctx.setOptions({ root });
|
|
102
|
+
ctx$1.setOptions({ root });
|
|
188
103
|
},
|
|
189
104
|
async buildStart() {
|
|
190
|
-
ctx.createInfo();
|
|
105
|
+
ctx$1.createInfo();
|
|
191
106
|
},
|
|
192
107
|
configureServer(server) {
|
|
193
108
|
const _printUrls = server.printUrls;
|
|
@@ -200,31 +115,40 @@ function appInfo() {
|
|
|
200
115
|
}
|
|
201
116
|
|
|
202
117
|
//#endregion
|
|
203
|
-
//#region src/plugins/inject-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
118
|
+
//#region src/plugins/built-in/inject-auto.ts
|
|
119
|
+
/**
|
|
120
|
+
* 自动注入代码
|
|
121
|
+
*/
|
|
122
|
+
function createInjectAuto(options) {
|
|
123
|
+
const { id } = options;
|
|
124
|
+
let entryFiles = [];
|
|
125
|
+
return {
|
|
126
|
+
name: "vite-plugin-inject-auto",
|
|
127
|
+
enforce: "pre",
|
|
128
|
+
configResolved(config) {
|
|
129
|
+
const lib = config.build?.lib;
|
|
130
|
+
if (!lib || !lib.entry) return;
|
|
131
|
+
const toAbs = (p) => resolve(config.root, p);
|
|
132
|
+
if (typeof lib.entry === "string") entryFiles = [toAbs(lib.entry)];
|
|
133
|
+
else if (Array.isArray(lib.entry)) entryFiles = lib.entry.map(toAbs);
|
|
134
|
+
else if (typeof lib.entry === "object") entryFiles = Object.values(lib.entry).map(toAbs);
|
|
135
|
+
},
|
|
136
|
+
transform(code, _id) {
|
|
137
|
+
if (entryFiles.includes(_id)) return `
|
|
138
|
+
import { defineRouteModule, defineIconModule } from 'pubinfo';
|
|
139
|
+
import modules from 'virtual:pubinfo-resolver';
|
|
207
140
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
function createInspector(env) {
|
|
211
|
-
const { VITE_APP_INSPECTOR } = env;
|
|
212
|
-
if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") return VueDevTools();
|
|
213
|
-
else return null;
|
|
214
|
-
}
|
|
141
|
+
defineRouteModule('${id}', modules.pages);
|
|
142
|
+
defineIconModule('${id}', modules.icons);
|
|
215
143
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return vueLegacy({
|
|
221
|
-
modernPolyfills: ["es.array.at", "es.array.find-last"],
|
|
222
|
-
additionalLegacyPolyfills: ["abort-controller/polyfill"]
|
|
223
|
-
});
|
|
144
|
+
${code}
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
224
148
|
}
|
|
225
149
|
|
|
226
150
|
//#endregion
|
|
227
|
-
//#region src/plugins/lib-resolver.ts
|
|
151
|
+
//#region src/plugins/built-in/lib-resolver.ts
|
|
228
152
|
function getPatternBase(pattern) {
|
|
229
153
|
const parts = pattern.split("/");
|
|
230
154
|
const baseParts = [];
|
|
@@ -333,32 +257,24 @@ function createLibResolver(options) {
|
|
|
333
257
|
}
|
|
334
258
|
|
|
335
259
|
//#endregion
|
|
336
|
-
//#region src/plugins/
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
function createOpenAPI(options) {
|
|
351
|
-
return OpenAPI(options || { enabled: false });
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/plugins/unocss.ts
|
|
356
|
-
function createUnocss() {
|
|
357
|
-
return Unocss();
|
|
260
|
+
//#region src/plugins/built-in/system-info.ts
|
|
261
|
+
function createSystemInfo(options = {}) {
|
|
262
|
+
const defineKey = options.defineKey || "__SYSTEM_INFO__";
|
|
263
|
+
return {
|
|
264
|
+
name: "vite-plugin-system-info",
|
|
265
|
+
async config() {
|
|
266
|
+
const pkg = await readPackageJSON();
|
|
267
|
+
const systemInfo = {
|
|
268
|
+
buildTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
|
269
|
+
pkg
|
|
270
|
+
};
|
|
271
|
+
return { define: { [defineKey]: JSON.stringify(systemInfo) } };
|
|
272
|
+
}
|
|
273
|
+
};
|
|
358
274
|
}
|
|
359
275
|
|
|
360
276
|
//#endregion
|
|
361
|
-
//#region src/plugins/virtual-inspector.ts
|
|
277
|
+
//#region src/plugins/built-in/virtual-inspector.ts
|
|
362
278
|
function getInspectorPath() {
|
|
363
279
|
return normalizePath(dirname(fileURLToPath(import.meta.url)));
|
|
364
280
|
}
|
|
@@ -422,6 +338,189 @@ function createVirtualInspector(options) {
|
|
|
422
338
|
return createVirtualInspectorPlugin(options);
|
|
423
339
|
}
|
|
424
340
|
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/plugins/built-in/zip.ts
|
|
343
|
+
var Ctx = class {
|
|
344
|
+
root;
|
|
345
|
+
outDirName;
|
|
346
|
+
dir;
|
|
347
|
+
outDir;
|
|
348
|
+
setOptions(options) {
|
|
349
|
+
this.root = options.root;
|
|
350
|
+
this.outDirName = options.outDirName;
|
|
351
|
+
this.getDirPath();
|
|
352
|
+
}
|
|
353
|
+
getDirPath() {
|
|
354
|
+
const dir = resolve(this.root, this.outDirName);
|
|
355
|
+
const outDir = `${dir}.zip`;
|
|
356
|
+
this.dir = dir;
|
|
357
|
+
this.outDir = outDir;
|
|
358
|
+
}
|
|
359
|
+
async clean() {
|
|
360
|
+
if (await fse.pathExists(this.outDir)) fse.remove(this.outDir);
|
|
361
|
+
}
|
|
362
|
+
async compress() {
|
|
363
|
+
const zip = new JSZip();
|
|
364
|
+
const files = this.getAllFiles(this.dir);
|
|
365
|
+
if (files && Array.isArray(files) && files.length) files.forEach((file) => {
|
|
366
|
+
const fileData = readFileSync(file, { encoding: "binary" });
|
|
367
|
+
zip.file(relative(this.dir, file), fileData, { binary: true });
|
|
368
|
+
});
|
|
369
|
+
const content = await zip.generateAsync({ type: "arraybuffer" });
|
|
370
|
+
writeFileSync(this.outDir, Buffer.from(content));
|
|
371
|
+
}
|
|
372
|
+
getAllFiles(dirPath) {
|
|
373
|
+
const files = readdirSync(dirPath);
|
|
374
|
+
const result = [];
|
|
375
|
+
for (const file of files) {
|
|
376
|
+
const filePath = join(dirPath, file);
|
|
377
|
+
if (statSync(filePath).isDirectory()) result.push(...this.getAllFiles(filePath));
|
|
378
|
+
else result.push(filePath);
|
|
379
|
+
}
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const ctx = new Ctx();
|
|
384
|
+
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/plugins/intergrations/auto-import.ts
|
|
387
|
+
function createAutoImport() {
|
|
388
|
+
return {
|
|
389
|
+
...autoImport({
|
|
390
|
+
imports: [
|
|
391
|
+
"vue",
|
|
392
|
+
"vue-router",
|
|
393
|
+
"pinia",
|
|
394
|
+
{ pubinfo: ["useAuth"] }
|
|
395
|
+
],
|
|
396
|
+
ignore: ["h"],
|
|
397
|
+
dts: "./.pubinfo/auto-imports.d.ts",
|
|
398
|
+
resolvers: [AntDesignVueResolver(), IconsResolver({ prefix: "i" })]
|
|
399
|
+
}),
|
|
400
|
+
enforce: "pre"
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/plugins/intergrations/components.ts
|
|
406
|
+
function createComponents() {
|
|
407
|
+
return components({
|
|
408
|
+
dirs: ["src/components"],
|
|
409
|
+
directives: true,
|
|
410
|
+
include: [
|
|
411
|
+
/\.vue$/,
|
|
412
|
+
/\.vue\?vue/,
|
|
413
|
+
/\.tsx$/
|
|
414
|
+
],
|
|
415
|
+
resolvers: [
|
|
416
|
+
IconsResolver(),
|
|
417
|
+
AntDesignVueResolver({
|
|
418
|
+
resolveIcons: true,
|
|
419
|
+
importStyle: false
|
|
420
|
+
}),
|
|
421
|
+
{
|
|
422
|
+
type: "component",
|
|
423
|
+
resolve(name) {
|
|
424
|
+
if ([
|
|
425
|
+
"PubinfoApp",
|
|
426
|
+
"PubinfoProvider",
|
|
427
|
+
"PubinfoIcon"
|
|
428
|
+
].includes(name)) return {
|
|
429
|
+
name,
|
|
430
|
+
from: "pubinfo"
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
dts: "./.pubinfo/components.d.ts"
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/plugins/intergrations/compression.ts
|
|
441
|
+
function createCompression(env) {
|
|
442
|
+
const { VITE_BUILD_COMPRESS } = env;
|
|
443
|
+
const compressList = VITE_BUILD_COMPRESS?.split(",") ?? [];
|
|
444
|
+
const plugin = [];
|
|
445
|
+
if (compressList.includes("gzip")) plugin.push(compression({
|
|
446
|
+
ext: ".gz",
|
|
447
|
+
deleteOriginFile: false
|
|
448
|
+
}));
|
|
449
|
+
if (compressList.includes("brotli")) plugin.push(compression({
|
|
450
|
+
ext: ".br",
|
|
451
|
+
algorithm: "brotliCompress",
|
|
452
|
+
deleteOriginFile: false
|
|
453
|
+
}));
|
|
454
|
+
return plugin;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/plugins/intergrations/dts.ts
|
|
459
|
+
function createDTS() {
|
|
460
|
+
return {
|
|
461
|
+
...dts({
|
|
462
|
+
clearPureImport: false,
|
|
463
|
+
exclude: ["tests/**/*"]
|
|
464
|
+
}),
|
|
465
|
+
enforce: "post"
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/plugins/intergrations/icon.ts
|
|
471
|
+
function createIcons() {
|
|
472
|
+
return Icons({ autoInstall: false });
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/plugins/intergrations/inject-css.ts
|
|
477
|
+
function createInjectCSS() {
|
|
478
|
+
return libInjectCss();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/plugins/intergrations/inspector.ts
|
|
483
|
+
function createInspector(env) {
|
|
484
|
+
const { VITE_APP_INSPECTOR } = env;
|
|
485
|
+
if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") return VueDevTools();
|
|
486
|
+
else return null;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/plugins/intergrations/legacy.ts
|
|
491
|
+
function createLegacy(env) {
|
|
492
|
+
if (env.VITE_BUILD_LEGACY !== "true") return false;
|
|
493
|
+
return vueLegacy({
|
|
494
|
+
modernPolyfills: ["es.array.at", "es.array.find-last"],
|
|
495
|
+
additionalLegacyPolyfills: ["abort-controller/polyfill"]
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/plugins/intergrations/mock.ts
|
|
501
|
+
function createMock(env, isBuild) {
|
|
502
|
+
const { VITE_BUILD_MOCK } = env;
|
|
503
|
+
if (!existsSync(resolve(cwd(), "src/mock"))) return;
|
|
504
|
+
return vitePluginFakeServer({
|
|
505
|
+
logger: !isBuild,
|
|
506
|
+
include: "src/mock",
|
|
507
|
+
infixName: false,
|
|
508
|
+
enableProd: isBuild && VITE_BUILD_MOCK === "true"
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/plugins/intergrations/openapi.ts
|
|
514
|
+
function createOpenAPI(options) {
|
|
515
|
+
return OpenAPI(options || { enabled: false });
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/plugins/intergrations/unocss.ts
|
|
520
|
+
function createUnocss() {
|
|
521
|
+
return Unocss();
|
|
522
|
+
}
|
|
523
|
+
|
|
425
524
|
//#endregion
|
|
426
525
|
//#region src/plugins/index.ts
|
|
427
526
|
function createVitePlugins(viteEnv, isBuild = false, config, type) {
|
|
@@ -437,9 +536,14 @@ function createVitePlugins(viteEnv, isBuild = false, config, type) {
|
|
|
437
536
|
createInspector(viteEnv),
|
|
438
537
|
createOpenAPI(config.openapi),
|
|
439
538
|
createLibResolver(config.resolver),
|
|
440
|
-
|
|
539
|
+
createAppInfo(),
|
|
441
540
|
createVirtualInspector({ enabled: true }),
|
|
442
|
-
|
|
541
|
+
createSystemInfo(),
|
|
542
|
+
type === "module" ? [
|
|
543
|
+
createDTS(),
|
|
544
|
+
createInjectCSS(),
|
|
545
|
+
createInjectAuto({ id: config.moduleId })
|
|
546
|
+
] : null,
|
|
443
547
|
isBuild ? createCompression(viteEnv) : null
|
|
444
548
|
].filter(Boolean);
|
|
445
549
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.5",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
19
|
+
},
|
|
17
20
|
"peerDependencies": {
|
|
18
21
|
"vue": "^3.5.17"
|
|
19
22
|
},
|
|
@@ -27,11 +30,13 @@
|
|
|
27
30
|
"chalk": "^5.4.1",
|
|
28
31
|
"chokidar": "^4.0.1",
|
|
29
32
|
"consola": "^3.4.2",
|
|
33
|
+
"dayjs": "^1.11.13",
|
|
30
34
|
"fast-glob": "^3.3.3",
|
|
31
35
|
"fs-extra": "^11.3.0",
|
|
32
36
|
"jszip": "^3.10.1",
|
|
33
37
|
"lodash-es": "^4.17.21",
|
|
34
38
|
"picomatch": "^4.0.3",
|
|
39
|
+
"pkg-types": "^2.3.0",
|
|
35
40
|
"rolldown-vite": "^7.1.2",
|
|
36
41
|
"terser": "^5.43.1",
|
|
37
42
|
"unocss": "^66.4.2",
|