@pubinfo/vite 0.6.7 → 0.6.10
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.mts +2 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +163 -260
- package/package.json +19 -20
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import { UserConfig } from 'vite';
|
|
2
|
+
import { UserConfig, UserConfigFnObject } from 'vite';
|
|
3
3
|
|
|
4
|
-
declare function defineConfig(defineOptions?: UserConfig): vite.UserConfigExport;
|
|
4
|
+
declare function defineConfig(defineOptions?: UserConfig | UserConfigFnObject): vite.UserConfigExport;
|
|
5
5
|
|
|
6
6
|
export { defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
/// <reference types="@intlify/unplugin-vue-i18n/messages" />
|
|
3
3
|
/// <reference types="unplugin-icons/types/vue" />
|
|
4
|
-
/// <reference types="vite-plugin-vue-meta-layouts/client" />
|
|
5
4
|
|
|
6
5
|
import * as vite from 'vite';
|
|
7
|
-
import { UserConfig } from 'vite';
|
|
6
|
+
import { UserConfig, UserConfigFnObject } from 'vite';
|
|
8
7
|
|
|
9
|
-
declare function defineConfig(defineOptions?: UserConfig): vite.UserConfigExport;
|
|
8
|
+
declare function defineConfig(defineOptions?: UserConfig | UserConfigFnObject): vite.UserConfigExport;
|
|
10
9
|
|
|
11
10
|
export { defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,90 @@
|
|
|
1
|
+
import path, { resolve as resolve$1 } from 'node:path';
|
|
1
2
|
import process from 'node:process';
|
|
2
|
-
import path, { resolve as resolve$1, relative, join } from 'node:path';
|
|
3
3
|
import { defineConfig as defineConfig$1, loadEnv, mergeConfig } from 'vite';
|
|
4
|
+
import fs from 'node:fs/promises';
|
|
5
|
+
import { readPackageJSON } from 'pkg-types';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import consola from 'consola';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import vueLegacy from '@vitejs/plugin-legacy';
|
|
4
10
|
import vue from '@vitejs/plugin-vue';
|
|
5
11
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
6
|
-
import vueLegacy from '@vitejs/plugin-legacy';
|
|
7
12
|
import autoImport from 'unplugin-auto-import/vite';
|
|
8
13
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
|
9
14
|
import IconsResolver from 'unplugin-icons/resolver';
|
|
15
|
+
import banner from 'vite-plugin-banner';
|
|
10
16
|
import components from 'unplugin-vue-components/vite';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
17
|
+
import compression from 'vite-plugin-compression';
|
|
18
|
+
import TurboConsole from 'unplugin-turbo-console/vite';
|
|
13
19
|
import vueI18n from '@intlify/unplugin-vue-i18n/vite';
|
|
20
|
+
import { existsSync } from 'node:fs';
|
|
14
21
|
import { vitePluginFakeServer } from 'vite-plugin-fake-server';
|
|
15
|
-
import Layouts from 'vite-plugin-vue-meta-layouts';
|
|
16
|
-
import compression from 'vite-plugin-compression';
|
|
17
|
-
import banner from 'vite-plugin-banner';
|
|
18
|
-
import dayjs from 'dayjs';
|
|
19
22
|
import fg from 'fast-glob';
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import JSZip from 'jszip';
|
|
23
|
-
import fse from 'fs-extra/esm';
|
|
24
|
-
import consola$1, { consola } from 'consola';
|
|
23
|
+
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
|
24
|
+
import Unocss from 'unocss/vite';
|
|
25
25
|
import Icons from 'unplugin-icons/vite';
|
|
26
|
-
import TurboConsole from 'unplugin-turbo-console/vite';
|
|
27
26
|
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
28
27
|
import OpenAPI from '@pubinfo/unplugin-openapi/vite';
|
|
29
|
-
import EnvRuntime from 'vite-plugin-env-runtime';
|
|
30
28
|
import boxen from 'boxen';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
|
|
30
|
+
function cleanse() {
|
|
31
|
+
return {
|
|
32
|
+
name: "esbuild-plugin-cleanse",
|
|
33
|
+
setup(build) {
|
|
34
|
+
build.onLoad({ filter: /\/dist\/alova\.esm\.js$/ }, async (args) => {
|
|
35
|
+
let alovaContnet = await fs.readFile(args.path, "utf-8");
|
|
36
|
+
alovaContnet = alovaContnet.replace(/\/\* c8 ignore start \*\/[\s\S]*?\/\* c8 ignore stop \*\//g, "");
|
|
37
|
+
return {
|
|
38
|
+
contents: `${alovaContnet}`
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function createDefineSystemInfo(root) {
|
|
46
|
+
try {
|
|
47
|
+
const pkgJson = await readPackageJSON(root);
|
|
48
|
+
const { dependencies, devDependencies, version } = pkgJson;
|
|
49
|
+
const lastBuildTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
|
50
|
+
const SYSTEM_INFO = {
|
|
51
|
+
pkg: {
|
|
52
|
+
dependencies,
|
|
53
|
+
devDependencies,
|
|
54
|
+
version
|
|
55
|
+
},
|
|
56
|
+
lastBuildTime
|
|
57
|
+
};
|
|
58
|
+
return JSON.stringify(SYSTEM_INFO);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function getServerProxy(env, isProxy, rewrite = true) {
|
|
64
|
+
if (!isProxy) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
const targetPrefix = "VITE_APP_API_";
|
|
68
|
+
const proxyKey = Object.keys(env).filter((key) => key.startsWith(targetPrefix));
|
|
69
|
+
const serverProxy = {};
|
|
70
|
+
for (const envKey of proxyKey) {
|
|
71
|
+
const url = env[envKey];
|
|
72
|
+
const { pathname } = new URL(url);
|
|
73
|
+
const pk = `${pathname}/proxy`;
|
|
74
|
+
if (pk in serverProxy) {
|
|
75
|
+
consola.error(`The proxy key ${chalk.bold.redBright(envKey)} \u279C ${chalk.bold.yellowBright(url)} already exists`);
|
|
76
|
+
} else {
|
|
77
|
+
serverProxy[pk] = {
|
|
78
|
+
target: url,
|
|
79
|
+
changeOrigin: rewrite,
|
|
80
|
+
rewrite: (path) => {
|
|
81
|
+
return path.replace(pk, "");
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return serverProxy;
|
|
87
|
+
}
|
|
34
88
|
|
|
35
89
|
function resolve(name) {
|
|
36
90
|
if (!name.startsWith("usePub")) {
|
|
@@ -77,6 +131,17 @@ function createAutoImport() {
|
|
|
77
131
|
});
|
|
78
132
|
}
|
|
79
133
|
|
|
134
|
+
const deploymentTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
|
135
|
+
function createBanner() {
|
|
136
|
+
return banner(`
|
|
137
|
+
/**
|
|
138
|
+
* \u7531 \u793E\u4F1A\u6CBB\u7406\u4E8B\u4E1A\u90E8 \u63D0\u4F9B\u6280\u672F\u652F\u6301
|
|
139
|
+
* Powered by wsy-admin
|
|
140
|
+
* ${deploymentTime}
|
|
141
|
+
*/
|
|
142
|
+
`);
|
|
143
|
+
}
|
|
144
|
+
|
|
80
145
|
function resolveComponent(componentName) {
|
|
81
146
|
if (!componentName.match(/^Pub[A-Z]/)) {
|
|
82
147
|
return;
|
|
@@ -133,45 +198,9 @@ function createComponents() {
|
|
|
133
198
|
});
|
|
134
199
|
}
|
|
135
200
|
|
|
136
|
-
function createUnocss() {
|
|
137
|
-
return Unocss();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function createSvgIcon(isBuild) {
|
|
141
|
-
return createSvgIconsPlugin({
|
|
142
|
-
iconDirs: [path.resolve(process.cwd(), "src/assets/icons/")],
|
|
143
|
-
symbolId: "icon-[dir]-[name]",
|
|
144
|
-
svgoOptions: isBuild
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function createI18n() {
|
|
149
|
-
const root = process.cwd();
|
|
150
|
-
const pathResolve = (pathname) => resolve$1(root, ".", pathname);
|
|
151
|
-
return vueI18n({
|
|
152
|
-
include: `${pathResolve("src")}/locales/lang/**`
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function createMock(env, isBuild) {
|
|
157
|
-
const { VITE_BUILD_MOCK } = env;
|
|
158
|
-
return vitePluginFakeServer({
|
|
159
|
-
logger: !isBuild,
|
|
160
|
-
include: "src/mock",
|
|
161
|
-
infixName: false,
|
|
162
|
-
enableProd: isBuild && VITE_BUILD_MOCK === "true"
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function createLayouts() {
|
|
167
|
-
return Layouts({
|
|
168
|
-
defaultLayout: "index"
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
201
|
function createCompression(env) {
|
|
173
202
|
const { VITE_BUILD_COMPRESS } = env;
|
|
174
|
-
const compressList = VITE_BUILD_COMPRESS
|
|
203
|
+
const compressList = VITE_BUILD_COMPRESS?.split(",") ?? [];
|
|
175
204
|
const plugin = [];
|
|
176
205
|
if (compressList.includes("gzip")) {
|
|
177
206
|
plugin.push(
|
|
@@ -193,29 +222,46 @@ function createCompression(env) {
|
|
|
193
222
|
return plugin;
|
|
194
223
|
}
|
|
195
224
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* \u7531 \u793E\u4F1A\u6CBB\u7406\u4E8B\u4E1A\u90E8 \u63D0\u4F9B\u6280\u672F\u652F\u6301
|
|
201
|
-
* Powered by wsy-admin
|
|
202
|
-
* ${deploymentTime}
|
|
203
|
-
*/
|
|
204
|
-
`);
|
|
225
|
+
function createConsole() {
|
|
226
|
+
return TurboConsole({
|
|
227
|
+
disableLaunchEditor: true
|
|
228
|
+
});
|
|
205
229
|
}
|
|
206
230
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
231
|
+
function createI18n() {
|
|
232
|
+
const root = process.cwd();
|
|
233
|
+
const pathResolve = (pathname) => resolve$1(root, ".", pathname);
|
|
234
|
+
return vueI18n({
|
|
235
|
+
include: `${pathResolve("src")}/locales/lang/**`
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function createMock(env, isBuild) {
|
|
240
|
+
const { VITE_BUILD_MOCK } = env;
|
|
241
|
+
const root = process.cwd();
|
|
242
|
+
if (!existsSync(resolve$1(root, "src/mock"))) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
return vitePluginFakeServer({
|
|
246
|
+
logger: !isBuild,
|
|
247
|
+
include: "src/mock",
|
|
248
|
+
infixName: false,
|
|
249
|
+
enableProd: isBuild && VITE_BUILD_MOCK === "true"
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var __defProp$1 = Object.defineProperty;
|
|
254
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
255
|
+
var __publicField$1 = (obj, key, value) => {
|
|
256
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
211
257
|
return value;
|
|
212
258
|
};
|
|
213
|
-
let Ctx$
|
|
259
|
+
let Ctx$1 = class Ctx {
|
|
214
260
|
constructor(options) {
|
|
215
|
-
__publicField$
|
|
216
|
-
__publicField$
|
|
217
|
-
__publicField$
|
|
218
|
-
__publicField$
|
|
261
|
+
__publicField$1(this, "root");
|
|
262
|
+
__publicField$1(this, "globs");
|
|
263
|
+
__publicField$1(this, "sourcePath");
|
|
264
|
+
__publicField$1(this, "path");
|
|
219
265
|
this.globs = options.globs;
|
|
220
266
|
}
|
|
221
267
|
setRoot(root) {
|
|
@@ -238,7 +284,7 @@ let Ctx$2 = class Ctx {
|
|
|
238
284
|
}
|
|
239
285
|
};
|
|
240
286
|
function scssPreprocessor(options) {
|
|
241
|
-
const ctx = new Ctx$
|
|
287
|
+
const ctx = new Ctx$1(options);
|
|
242
288
|
return {
|
|
243
289
|
name: "vite-plugin-scssPreprocessor",
|
|
244
290
|
enforce: "pre",
|
|
@@ -263,91 +309,16 @@ function createPreprocessor() {
|
|
|
263
309
|
});
|
|
264
310
|
}
|
|
265
311
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
};
|
|
272
|
-
let Ctx$1 = class Ctx {
|
|
273
|
-
constructor() {
|
|
274
|
-
__publicField$1(this, "root");
|
|
275
|
-
__publicField$1(this, "outDirName");
|
|
276
|
-
__publicField$1(this, "dir");
|
|
277
|
-
__publicField$1(this, "outDir");
|
|
278
|
-
}
|
|
279
|
-
setOptions(options) {
|
|
280
|
-
this.root = options.root;
|
|
281
|
-
this.outDirName = options.outDirName;
|
|
282
|
-
this.getDirPath();
|
|
283
|
-
}
|
|
284
|
-
getDirPath() {
|
|
285
|
-
const dir = resolve$1(this.root, this.outDirName);
|
|
286
|
-
const outDir = `${dir}.zip`;
|
|
287
|
-
this.dir = dir;
|
|
288
|
-
this.outDir = outDir;
|
|
289
|
-
}
|
|
290
|
-
async clean() {
|
|
291
|
-
const pathExists = await fse.pathExists(this.outDir);
|
|
292
|
-
if (pathExists) {
|
|
293
|
-
fse.remove(this.outDir);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
async compress() {
|
|
297
|
-
const zip = new JSZip();
|
|
298
|
-
const files = this.getAllFiles(this.dir);
|
|
299
|
-
if (files && Array.isArray(files) && files.length) {
|
|
300
|
-
files.forEach((file) => {
|
|
301
|
-
const fileData = readFileSync(file, { encoding: "binary" });
|
|
302
|
-
zip.file(relative(this.dir, file), fileData, { binary: true });
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
const content = await zip.generateAsync({ type: "arraybuffer" });
|
|
306
|
-
writeFileSync(this.outDir, Buffer.from(content));
|
|
307
|
-
}
|
|
308
|
-
getAllFiles(dirPath) {
|
|
309
|
-
const files = readdirSync(dirPath);
|
|
310
|
-
const result = [];
|
|
311
|
-
for (const file of files) {
|
|
312
|
-
const filePath = join(dirPath, file);
|
|
313
|
-
if (statSync(filePath).isDirectory()) {
|
|
314
|
-
result.push(...this.getAllFiles(filePath));
|
|
315
|
-
} else {
|
|
316
|
-
result.push(filePath);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return result;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
const ctx$1 = new Ctx$1();
|
|
323
|
-
function zipPack() {
|
|
324
|
-
return {
|
|
325
|
-
name: "vite-plugin-zip",
|
|
326
|
-
apply: "build",
|
|
327
|
-
enforce: "post",
|
|
328
|
-
configResolved(configuration) {
|
|
329
|
-
const outDirName = configuration.build.outDir;
|
|
330
|
-
const root = configuration.root;
|
|
331
|
-
ctx$1.setOptions({ root, outDirName });
|
|
332
|
-
},
|
|
333
|
-
buildEnd() {
|
|
334
|
-
let isCompress = false;
|
|
335
|
-
process.on("beforeExit", async () => {
|
|
336
|
-
if (isCompress) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
consola.start("\u5C06\u6587\u4EF6\u5305\u538B\u7F29\u6210zip...");
|
|
340
|
-
isCompress = true;
|
|
341
|
-
await ctx$1.clean();
|
|
342
|
-
await ctx$1.compress();
|
|
343
|
-
consola.success("\u6587\u4EF6\u538B\u7F29\u5B8C\u6210");
|
|
344
|
-
consola.success("\u6253\u5305\u6D41\u7A0B\u7ED3\u675F!");
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
};
|
|
312
|
+
function createSvgIcon(isBuild) {
|
|
313
|
+
return createSvgIconsPlugin({
|
|
314
|
+
iconDirs: [path.resolve(process.cwd(), "src/assets/icons/")],
|
|
315
|
+
symbolId: "icon-[dir]-[name]",
|
|
316
|
+
svgoOptions: isBuild
|
|
317
|
+
});
|
|
348
318
|
}
|
|
349
|
-
|
|
350
|
-
|
|
319
|
+
|
|
320
|
+
function createUnocss() {
|
|
321
|
+
return Unocss();
|
|
351
322
|
}
|
|
352
323
|
|
|
353
324
|
function createIcons() {
|
|
@@ -356,12 +327,6 @@ function createIcons() {
|
|
|
356
327
|
});
|
|
357
328
|
}
|
|
358
329
|
|
|
359
|
-
function createConsole() {
|
|
360
|
-
return TurboConsole({
|
|
361
|
-
disableLaunchEditor: true
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
330
|
function createInspector(env) {
|
|
366
331
|
const { VITE_APP_INSPECTOR } = env;
|
|
367
332
|
if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") {
|
|
@@ -375,17 +340,6 @@ function createOpenAPI() {
|
|
|
375
340
|
return OpenAPI();
|
|
376
341
|
}
|
|
377
342
|
|
|
378
|
-
function createConfig() {
|
|
379
|
-
return EnvRuntime({
|
|
380
|
-
name: "__PRODUCTION__PUBINFO__CONFIG__",
|
|
381
|
-
filename: "config.js",
|
|
382
|
-
include: [
|
|
383
|
-
"VITE_APP_TITLE",
|
|
384
|
-
"VITE_APP_API_BASEURL"
|
|
385
|
-
]
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
|
|
389
343
|
var __defProp = Object.defineProperty;
|
|
390
344
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
391
345
|
var __publicField = (obj, key, value) => {
|
|
@@ -445,7 +399,13 @@ function createVitePlugins(viteEnv, isBuild = false) {
|
|
|
445
399
|
const vitePlugins = [
|
|
446
400
|
vue(),
|
|
447
401
|
vueJsx(),
|
|
448
|
-
vueLegacy(
|
|
402
|
+
vueLegacy({
|
|
403
|
+
modernPolyfills: [
|
|
404
|
+
"es.array.at",
|
|
405
|
+
"es.array.find-last"
|
|
406
|
+
],
|
|
407
|
+
additionalLegacyPolyfills: ["abort-controller/polyfill"]
|
|
408
|
+
}),
|
|
449
409
|
createAutoImport(),
|
|
450
410
|
createComponents(),
|
|
451
411
|
createUnocss(),
|
|
@@ -453,14 +413,13 @@ function createVitePlugins(viteEnv, isBuild = false) {
|
|
|
453
413
|
createIcons(),
|
|
454
414
|
createI18n(),
|
|
455
415
|
createMock(viteEnv, isBuild),
|
|
456
|
-
createLayouts(),
|
|
457
416
|
createBanner(),
|
|
458
417
|
createPreprocessor(),
|
|
459
|
-
createZip(),
|
|
418
|
+
// createZip(),
|
|
460
419
|
createConsole(),
|
|
461
420
|
createInspector(viteEnv),
|
|
462
421
|
createOpenAPI(),
|
|
463
|
-
createConfig(),
|
|
422
|
+
// createConfig(),
|
|
464
423
|
appInfo()
|
|
465
424
|
];
|
|
466
425
|
const buildPlugins = () => [
|
|
@@ -472,75 +431,16 @@ function createVitePlugins(viteEnv, isBuild = false) {
|
|
|
472
431
|
return vitePlugins.filter(Boolean);
|
|
473
432
|
}
|
|
474
433
|
|
|
475
|
-
async function createDefineSystemInfo(root) {
|
|
476
|
-
try {
|
|
477
|
-
const pkgJson = await readPackageJSON(root);
|
|
478
|
-
const { dependencies, devDependencies, version } = pkgJson;
|
|
479
|
-
const lastBuildTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
|
480
|
-
const SYSTEM_INFO = {
|
|
481
|
-
pkg: {
|
|
482
|
-
dependencies,
|
|
483
|
-
devDependencies,
|
|
484
|
-
version
|
|
485
|
-
},
|
|
486
|
-
lastBuildTime
|
|
487
|
-
};
|
|
488
|
-
return JSON.stringify(SYSTEM_INFO);
|
|
489
|
-
} catch (error) {
|
|
490
|
-
return "";
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
function getServerProxy(env, isProxy, rewrite = true) {
|
|
494
|
-
if (!isProxy) {
|
|
495
|
-
return {};
|
|
496
|
-
}
|
|
497
|
-
const targetPrefix = "VITE_APP_API_";
|
|
498
|
-
const proxyKey = Object.keys(env).filter((key) => key.startsWith(targetPrefix));
|
|
499
|
-
const serverProxy = {};
|
|
500
|
-
for (const envKey of proxyKey) {
|
|
501
|
-
const url = env[envKey];
|
|
502
|
-
const { pathname } = new URL(url);
|
|
503
|
-
const pk = `${pathname}/proxy`;
|
|
504
|
-
if (pk in serverProxy) {
|
|
505
|
-
consola$1.error(`The proxy key ${chalk.bold.redBright(envKey)} \u279C ${chalk.bold.yellowBright(url)} already exists`);
|
|
506
|
-
} else {
|
|
507
|
-
serverProxy[pk] = {
|
|
508
|
-
target: url,
|
|
509
|
-
changeOrigin: rewrite,
|
|
510
|
-
rewrite: (path) => {
|
|
511
|
-
return path.replace(pk, "");
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
return serverProxy;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
function cleanse() {
|
|
520
|
-
return {
|
|
521
|
-
name: "esbuild-plugin-cleanse",
|
|
522
|
-
setup(build) {
|
|
523
|
-
build.onLoad({ filter: /\/dist\/alova\.esm\.js$/ }, async (args) => {
|
|
524
|
-
let alovaContnet = await fs.readFile(args.path, "utf-8");
|
|
525
|
-
alovaContnet = alovaContnet.replace(/\/\* c8 ignore start \*\/[\s\S]*?\/\* c8 ignore stop \*\//g, "");
|
|
526
|
-
return {
|
|
527
|
-
contents: `${alovaContnet}`
|
|
528
|
-
};
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
|
|
534
434
|
function defineConfig(defineOptions = {}) {
|
|
535
435
|
return defineConfig$1(async ({ mode, command }) => {
|
|
536
436
|
const root = process.cwd();
|
|
537
437
|
const pathResolve = (pathname) => resolve$1(root, ".", pathname);
|
|
538
|
-
const
|
|
539
|
-
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
438
|
+
const __SYSTEM_INFO__ = await createDefineSystemInfo(root);
|
|
540
439
|
const isBuild = command === "build";
|
|
440
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
441
|
+
const env = loadEnv(mode, root);
|
|
541
442
|
const { VITE_OPEN_PROXY, VITE_BUILD_SOURCEMAP } = env;
|
|
542
443
|
const serverProxy = getServerProxy(env, !isBuild && VITE_OPEN_PROXY === "true");
|
|
543
|
-
const __SYSTEM_INFO__ = await createDefineSystemInfo(root);
|
|
544
444
|
const applicationConfig = {
|
|
545
445
|
base: "./",
|
|
546
446
|
server: {
|
|
@@ -571,17 +471,17 @@ function defineConfig(defineOptions = {}) {
|
|
|
571
471
|
]
|
|
572
472
|
},
|
|
573
473
|
optimizeDeps: {
|
|
574
|
-
include: [
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
],
|
|
474
|
+
// include: [
|
|
475
|
+
// 'ant-design-vue/es/locale/zh_CN',
|
|
476
|
+
// 'ant-design-vue/es/locale/en_US',
|
|
477
|
+
// '@ant-design/icons-vue',
|
|
478
|
+
// 'dayjs',
|
|
479
|
+
// 'dayjs/locale/eu',
|
|
480
|
+
// 'dayjs/locale/zh-cn',
|
|
481
|
+
// '@pubinfo/pro-components',
|
|
482
|
+
// 'qrcode',
|
|
483
|
+
// '@pubinfo/headlessui',
|
|
484
|
+
// ],
|
|
585
485
|
esbuildOptions: {
|
|
586
486
|
plugins: [
|
|
587
487
|
cleanse()
|
|
@@ -595,13 +495,13 @@ function defineConfig(defineOptions = {}) {
|
|
|
595
495
|
chunkSizeWarningLimit: 2e3,
|
|
596
496
|
rollupOptions: {
|
|
597
497
|
output: {
|
|
598
|
-
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js
|
|
599
|
-
manualChunks: {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
498
|
+
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`
|
|
499
|
+
// manualChunks: {
|
|
500
|
+
// vue: ['vue', 'pinia', 'vue-router'],
|
|
501
|
+
// lodash: ['lodash-es'],
|
|
502
|
+
// antd: ['ant-design-vue', '@ant-design/icons-vue'],
|
|
503
|
+
// lottie: ['lottie-web'],
|
|
504
|
+
// },
|
|
605
505
|
}
|
|
606
506
|
}
|
|
607
507
|
},
|
|
@@ -612,7 +512,10 @@ function defineConfig(defineOptions = {}) {
|
|
|
612
512
|
},
|
|
613
513
|
plugins: createVitePlugins(env, isBuild)
|
|
614
514
|
};
|
|
615
|
-
return mergeConfig(
|
|
515
|
+
return mergeConfig(
|
|
516
|
+
applicationConfig,
|
|
517
|
+
typeof defineOptions === "function" ? defineOptions({ mode, command }) : defineOptions
|
|
518
|
+
);
|
|
616
519
|
});
|
|
617
520
|
}
|
|
618
521
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.10",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -20,39 +20,38 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@intlify/unplugin-vue-i18n": "^4.0.0",
|
|
23
|
-
"@pubinfo/unplugin-openapi": "^0.
|
|
24
|
-
"@vitejs/plugin-legacy": "^5.4.
|
|
25
|
-
"@vitejs/plugin-vue": "^5.
|
|
26
|
-
"@vitejs/plugin-vue-jsx": "^4.0.
|
|
27
|
-
"
|
|
23
|
+
"@pubinfo/unplugin-openapi": "^0.7.0",
|
|
24
|
+
"@vitejs/plugin-legacy": "^5.4.2",
|
|
25
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
26
|
+
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
27
|
+
"abort-controller": "^3.0.0",
|
|
28
|
+
"boxen": "^8.0.1",
|
|
28
29
|
"chalk": "^5.3.0",
|
|
29
30
|
"consola": "^3.2.3",
|
|
30
|
-
"dayjs": "^1.11.
|
|
31
|
+
"dayjs": "^1.11.13",
|
|
31
32
|
"fast-glob": "^3.3.2",
|
|
32
33
|
"fs-extra": "^11.2.0",
|
|
33
34
|
"jszip": "^3.10.1",
|
|
34
|
-
"pkg-types": "^1.
|
|
35
|
-
"terser": "^5.31.
|
|
36
|
-
"unocss": "^0.
|
|
37
|
-
"unplugin-auto-import": "^0.
|
|
38
|
-
"unplugin-icons": "^0.19.
|
|
39
|
-
"unplugin-turbo-console": "^1.
|
|
40
|
-
"unplugin-vue-components": "^0.27.
|
|
35
|
+
"pkg-types": "^1.2.0",
|
|
36
|
+
"terser": "^5.31.6",
|
|
37
|
+
"unocss": "^0.62.3",
|
|
38
|
+
"unplugin-auto-import": "^0.18.2",
|
|
39
|
+
"unplugin-icons": "^0.19.2",
|
|
40
|
+
"unplugin-turbo-console": "^1.10.1",
|
|
41
|
+
"unplugin-vue-components": "^0.27.4",
|
|
41
42
|
"vite-plugin-banner": "^0.7.1",
|
|
42
43
|
"vite-plugin-compression": "^0.5.1",
|
|
43
44
|
"vite-plugin-env-runtime": "^0.3.5",
|
|
44
45
|
"vite-plugin-fake-server": "^2.1.1",
|
|
45
46
|
"vite-plugin-pages": "^0.32.3",
|
|
46
47
|
"vite-plugin-svg-icons": "^2.0.1",
|
|
47
|
-
"vite-plugin-vue-devtools": "^7.3.
|
|
48
|
-
"vite-plugin-vue-meta-layouts": "^0.4.3"
|
|
48
|
+
"vite-plugin-vue-devtools": "^7.3.9"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/fs-extra": "^11.0.4",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"vue": "^
|
|
55
|
-
"vue-i18n": "^9.13.1"
|
|
52
|
+
"vite": "^5.4.8",
|
|
53
|
+
"vue": "^3.5.12",
|
|
54
|
+
"vue-i18n": "^10.0.4"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
57
|
"clean": "pnpm rimraf node_modules dist .turbo",
|