@pubinfo/vite 0.6.10 → 2.0.0-beta.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 +26 -3
- package/dist/index.d.ts +26 -7
- package/dist/index.mjs +184 -317
- package/package.json +26 -34
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _pubinfo_unplugin_openapi from '@pubinfo/unplugin-openapi';
|
|
2
|
+
import { Options } from '@pubinfo/unplugin-openapi';
|
|
2
3
|
import { UserConfig, UserConfigFnObject } from 'vite';
|
|
4
|
+
export * from 'vite';
|
|
5
|
+
export * from 'vite-plugin-fake-server/client';
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
interface PubinfoConfig {
|
|
8
|
+
/** `vite` */
|
|
9
|
+
vite?: UserConfig | UserConfigFnObject;
|
|
10
|
+
/** `@pubinfo/unplugin-openapi` */
|
|
11
|
+
openapi?: Options;
|
|
12
|
+
}
|
|
5
13
|
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 构建应用配置
|
|
16
|
+
*/
|
|
17
|
+
declare function definePubinfoConfig(config: PubinfoConfig): {
|
|
18
|
+
vite: UserConfigFnObject;
|
|
19
|
+
openapi?: _pubinfo_unplugin_openapi.Options;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 构建模块配置
|
|
23
|
+
*/
|
|
24
|
+
declare function defineModuleConfig(config: PubinfoConfig): {
|
|
25
|
+
vite: UserConfigFnObject;
|
|
26
|
+
openapi?: _pubinfo_unplugin_openapi.Options;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { type PubinfoConfig, defineModuleConfig, definePubinfoConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/// <reference types="unplugin-icons/types/vue" />
|
|
4
|
-
|
|
5
|
-
import * as vite from 'vite';
|
|
1
|
+
import * as _pubinfo_unplugin_openapi from '@pubinfo/unplugin-openapi';
|
|
2
|
+
import { Options } from '@pubinfo/unplugin-openapi';
|
|
6
3
|
import { UserConfig, UserConfigFnObject } from 'vite';
|
|
4
|
+
export * from 'vite';
|
|
5
|
+
export * from 'vite-plugin-fake-server/client';
|
|
6
|
+
|
|
7
|
+
interface PubinfoConfig {
|
|
8
|
+
/** `vite` */
|
|
9
|
+
vite?: UserConfig | UserConfigFnObject;
|
|
10
|
+
/** `@pubinfo/unplugin-openapi` */
|
|
11
|
+
openapi?: Options;
|
|
12
|
+
}
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 构建应用配置
|
|
16
|
+
*/
|
|
17
|
+
declare function definePubinfoConfig(config: PubinfoConfig): {
|
|
18
|
+
vite: UserConfigFnObject;
|
|
19
|
+
openapi?: _pubinfo_unplugin_openapi.Options;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 构建模块配置
|
|
23
|
+
*/
|
|
24
|
+
declare function defineModuleConfig(config: PubinfoConfig): {
|
|
25
|
+
vite: UserConfigFnObject;
|
|
26
|
+
openapi?: _pubinfo_unplugin_openapi.Options;
|
|
27
|
+
};
|
|
9
28
|
|
|
10
|
-
export {
|
|
29
|
+
export { type PubinfoConfig, defineModuleConfig, definePubinfoConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,66 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import fs from 'node:fs/promises';
|
|
5
|
-
import { readPackageJSON } from 'pkg-types';
|
|
6
|
-
import dayjs from 'dayjs';
|
|
7
|
-
import consola from 'consola';
|
|
1
|
+
import { loadEnv, defineConfig, mergeConfig } from 'vite';
|
|
2
|
+
export * from 'vite';
|
|
3
|
+
import { cwd } from 'node:process';
|
|
8
4
|
import chalk from 'chalk';
|
|
9
|
-
import
|
|
5
|
+
import consola from 'consola';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { join, resolve } from 'node:path';
|
|
10
8
|
import vue from '@vitejs/plugin-vue';
|
|
11
9
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
12
10
|
import autoImport from 'unplugin-auto-import/vite';
|
|
13
|
-
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
|
14
11
|
import IconsResolver from 'unplugin-icons/resolver';
|
|
15
|
-
import
|
|
12
|
+
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
|
16
13
|
import components from 'unplugin-vue-components/vite';
|
|
17
14
|
import compression from 'vite-plugin-compression';
|
|
18
|
-
import TurboConsole from 'unplugin-turbo-console/vite';
|
|
19
|
-
import vueI18n from '@intlify/unplugin-vue-i18n/vite';
|
|
20
|
-
import { existsSync } from 'node:fs';
|
|
21
|
-
import { vitePluginFakeServer } from 'vite-plugin-fake-server';
|
|
22
|
-
import fg from 'fast-glob';
|
|
23
|
-
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
|
|
24
|
-
import Unocss from 'unocss/vite';
|
|
25
15
|
import Icons from 'unplugin-icons/vite';
|
|
16
|
+
import boxen from 'boxen';
|
|
26
17
|
import VueDevTools from 'vite-plugin-vue-devtools';
|
|
18
|
+
import vueLegacy from '@vitejs/plugin-legacy';
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { vitePluginFakeServer } from 'vite-plugin-fake-server';
|
|
27
21
|
import OpenAPI from '@pubinfo/unplugin-openapi/vite';
|
|
28
|
-
import
|
|
22
|
+
import Unocss from 'unocss/vite';
|
|
23
|
+
export * from 'vite-plugin-fake-server/client';
|
|
29
24
|
|
|
30
|
-
function
|
|
25
|
+
function alias(root) {
|
|
26
|
+
const resolvePath = (name) => join(root, name);
|
|
27
|
+
const resolveDeps = (name, path) => join(createRequire(import.meta.url).resolve(name), path);
|
|
31
28
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
"@": resolvePath("src"),
|
|
30
|
+
"#": resolvePath("types"),
|
|
31
|
+
// 提供路径别名给 @pubinfo/core 直接调用项目中的文件
|
|
32
|
+
"pubinfo:project": resolvePath("src"),
|
|
33
|
+
// 显示的列出导出的目录
|
|
34
|
+
// '.pubinfo': resolvePath('.pubinfo/'),
|
|
35
|
+
// '.pubinfo/api': resolvePath('.pubinfo/api/'),
|
|
36
|
+
// '.pubinfo/assets': resolvePath('.pubinfo/assets/'),
|
|
37
|
+
// '.pubinfo/config': resolvePath('.pubinfo/config/'),
|
|
38
|
+
// '.pubinfo/directives': resolvePath('.pubinfo/directives/'),
|
|
39
|
+
// '.pubinfo/layout': resolvePath('.pubinfo/layout/'),
|
|
40
|
+
// '.pubinfo/locales': resolvePath('.pubinfo/locales/'),
|
|
41
|
+
// '.pubinfo/router': resolvePath('.pubinfo/router/'),
|
|
42
|
+
// '.pubinfo/store': resolvePath('.pubinfo/store/'),
|
|
43
|
+
// '.pubinfo/styles': resolvePath('.pubinfo/styles/'),
|
|
44
|
+
// '.pubinfo/themes': resolvePath('.pubinfo/themes/'),
|
|
45
|
+
// '.pubinfo/types': resolvePath('.pubinfo/types/'),
|
|
46
|
+
// '.pubinfo/utils': resolvePath('.pubinfo/utils/'),
|
|
47
|
+
// '.pubinfo/vue': resolvePath('.pubinfo/vue/'),
|
|
48
|
+
// deps
|
|
49
|
+
"vue": resolveDeps("vue", "../"),
|
|
50
|
+
"vue-router": resolveDeps("vue-router", "../"),
|
|
51
|
+
"pinia": resolveDeps("pinia", "../"),
|
|
52
|
+
"unocss": resolveDeps("unocss", "../")
|
|
42
53
|
};
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
|
|
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) {
|
|
56
|
+
function getServerProxy(env, isProxy) {
|
|
64
57
|
if (!isProxy) {
|
|
65
58
|
return {};
|
|
66
59
|
}
|
|
@@ -76,113 +69,47 @@ function getServerProxy(env, isProxy, rewrite = true) {
|
|
|
76
69
|
} else {
|
|
77
70
|
serverProxy[pk] = {
|
|
78
71
|
target: url,
|
|
79
|
-
changeOrigin:
|
|
80
|
-
rewrite: (path) =>
|
|
81
|
-
|
|
82
|
-
}
|
|
72
|
+
changeOrigin: true,
|
|
73
|
+
rewrite: (path) => path.replace(pk, ""),
|
|
74
|
+
secure: false
|
|
83
75
|
};
|
|
84
76
|
}
|
|
85
77
|
}
|
|
86
78
|
return serverProxy;
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
function resolve(name) {
|
|
90
|
-
if (!name.startsWith("usePub")) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
name,
|
|
95
|
-
from: "@pubinfo/composables"
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function PubInfoResolver$1() {
|
|
99
|
-
return (name) => {
|
|
100
|
-
return resolve(name);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
81
|
function createAutoImport() {
|
|
105
82
|
return autoImport({
|
|
106
83
|
imports: [
|
|
107
84
|
"vue",
|
|
108
85
|
"vue-router",
|
|
109
|
-
|
|
110
|
-
"
|
|
86
|
+
// 'vue-i18n',
|
|
87
|
+
"pinia",
|
|
111
88
|
{
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
"invalidateCache"
|
|
89
|
+
pubinfo: [
|
|
90
|
+
"useAuth"
|
|
115
91
|
]
|
|
116
92
|
}
|
|
117
93
|
],
|
|
94
|
+
// 解决代码混淆后出现的h和vue导入的h变量命名重复的问题
|
|
95
|
+
ignore: ["h"],
|
|
118
96
|
dts: "./types/auto-imports.d.ts",
|
|
119
97
|
dirs: [
|
|
120
|
-
"./src/
|
|
121
|
-
"./src/composables/**/*",
|
|
122
|
-
"./src/api/modules/**/*.ts"
|
|
98
|
+
"./src/composables/**/*"
|
|
123
99
|
],
|
|
124
100
|
resolvers: [
|
|
125
101
|
AntDesignVueResolver(),
|
|
126
102
|
IconsResolver({
|
|
127
103
|
prefix: "i"
|
|
128
|
-
})
|
|
129
|
-
PubInfoResolver$1()
|
|
104
|
+
})
|
|
130
105
|
]
|
|
131
106
|
});
|
|
132
107
|
}
|
|
133
108
|
|
|
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
|
-
|
|
145
|
-
function resolveComponent(componentName) {
|
|
146
|
-
if (!componentName.match(/^Pub[A-Z]/)) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
name: componentName,
|
|
151
|
-
as: componentName,
|
|
152
|
-
from: "@pubinfo/components"
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function resolveDirective(directiveName) {
|
|
156
|
-
if (!directiveName.match(/^Pub[A-Z]/)) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
name: directiveName,
|
|
161
|
-
from: "@pubinfo/directives"
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function PubInfoResolver() {
|
|
165
|
-
return [
|
|
166
|
-
{
|
|
167
|
-
type: "component",
|
|
168
|
-
resolve: async (name) => {
|
|
169
|
-
return resolveComponent(name);
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
type: "directive",
|
|
174
|
-
resolve: async (name) => {
|
|
175
|
-
return resolveDirective(name);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
109
|
function createComponents() {
|
|
182
110
|
return components({
|
|
183
111
|
dirs: [
|
|
184
|
-
"src/components"
|
|
185
|
-
"src/layouts/ui-kit"
|
|
112
|
+
"src/components"
|
|
186
113
|
],
|
|
187
114
|
directives: true,
|
|
188
115
|
include: [/\.vue$/, /\.vue\?vue/, /\.tsx$/],
|
|
@@ -192,7 +119,19 @@ function createComponents() {
|
|
|
192
119
|
resolveIcons: true,
|
|
193
120
|
importStyle: false
|
|
194
121
|
}),
|
|
195
|
-
|
|
122
|
+
{
|
|
123
|
+
type: "component",
|
|
124
|
+
resolve(name) {
|
|
125
|
+
const components2 = [
|
|
126
|
+
"PubinfoApp",
|
|
127
|
+
"PubinfoProvider",
|
|
128
|
+
"PubinfoIcon"
|
|
129
|
+
];
|
|
130
|
+
if (components2.includes(name)) {
|
|
131
|
+
return { name, from: "pubinfo" };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
196
135
|
],
|
|
197
136
|
dts: "./types/components.d.ts"
|
|
198
137
|
});
|
|
@@ -222,134 +161,14 @@ function createCompression(env) {
|
|
|
222
161
|
return plugin;
|
|
223
162
|
}
|
|
224
163
|
|
|
225
|
-
function createConsole() {
|
|
226
|
-
return TurboConsole({
|
|
227
|
-
disableLaunchEditor: true
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
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);
|
|
257
|
-
return value;
|
|
258
|
-
};
|
|
259
|
-
let Ctx$1 = class Ctx {
|
|
260
|
-
constructor(options) {
|
|
261
|
-
__publicField$1(this, "root");
|
|
262
|
-
__publicField$1(this, "globs");
|
|
263
|
-
__publicField$1(this, "sourcePath");
|
|
264
|
-
__publicField$1(this, "path");
|
|
265
|
-
this.globs = options.globs;
|
|
266
|
-
}
|
|
267
|
-
setRoot(root) {
|
|
268
|
-
this.root = root;
|
|
269
|
-
}
|
|
270
|
-
searchGlob() {
|
|
271
|
-
const { root, globs } = this;
|
|
272
|
-
this.sourcePath = fg.sync(globs, {
|
|
273
|
-
cwd: root,
|
|
274
|
-
onlyFiles: true
|
|
275
|
-
});
|
|
276
|
-
this.normalizePath();
|
|
277
|
-
}
|
|
278
|
-
normalizePath() {
|
|
279
|
-
const path = [];
|
|
280
|
-
for (const f of this.sourcePath) {
|
|
281
|
-
path.push(`@use "${f}" as *;`);
|
|
282
|
-
}
|
|
283
|
-
this.path = path.join("");
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
function scssPreprocessor(options) {
|
|
287
|
-
const ctx = new Ctx$1(options);
|
|
288
|
-
return {
|
|
289
|
-
name: "vite-plugin-scssPreprocessor",
|
|
290
|
-
enforce: "pre",
|
|
291
|
-
config: (config) => {
|
|
292
|
-
ctx.setRoot(config.root);
|
|
293
|
-
ctx.searchGlob();
|
|
294
|
-
return {
|
|
295
|
-
css: {
|
|
296
|
-
preprocessorOptions: {
|
|
297
|
-
scss: {
|
|
298
|
-
additionalData: ctx.path
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
function createPreprocessor() {
|
|
307
|
-
return scssPreprocessor({
|
|
308
|
-
globs: ["src/assets/styles/resources/*.scss"]
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
|
|
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
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function createUnocss() {
|
|
321
|
-
return Unocss();
|
|
322
|
-
}
|
|
323
|
-
|
|
324
164
|
function createIcons() {
|
|
325
165
|
return Icons({
|
|
326
166
|
autoInstall: false
|
|
327
167
|
});
|
|
328
168
|
}
|
|
329
169
|
|
|
330
|
-
function createInspector(env) {
|
|
331
|
-
const { VITE_APP_INSPECTOR } = env;
|
|
332
|
-
if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") {
|
|
333
|
-
return VueDevTools();
|
|
334
|
-
} else {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function createOpenAPI() {
|
|
340
|
-
return OpenAPI();
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
var __defProp = Object.defineProperty;
|
|
344
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
345
|
-
var __publicField = (obj, key, value) => {
|
|
346
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
347
|
-
return value;
|
|
348
|
-
};
|
|
349
170
|
class Ctx {
|
|
350
|
-
|
|
351
|
-
__publicField(this, "options");
|
|
352
|
-
}
|
|
171
|
+
options;
|
|
353
172
|
setOptions(options) {
|
|
354
173
|
this.options = options;
|
|
355
174
|
}
|
|
@@ -395,31 +214,61 @@ function appInfo() {
|
|
|
395
214
|
};
|
|
396
215
|
}
|
|
397
216
|
|
|
398
|
-
function
|
|
217
|
+
function createInspector(env) {
|
|
218
|
+
const { VITE_APP_INSPECTOR } = env;
|
|
219
|
+
if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") {
|
|
220
|
+
return VueDevTools();
|
|
221
|
+
} else {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function createLegacy(env) {
|
|
227
|
+
if (env.VITE_BUILD_LEGACY !== "true") {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
return vueLegacy({
|
|
231
|
+
modernPolyfills: [
|
|
232
|
+
"es.array.at",
|
|
233
|
+
"es.array.find-last"
|
|
234
|
+
],
|
|
235
|
+
additionalLegacyPolyfills: ["abort-controller/polyfill"]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function createMock(env, isBuild) {
|
|
240
|
+
const { VITE_BUILD_MOCK } = env;
|
|
241
|
+
if (!existsSync(resolve(cwd(), "src/mock"))) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
return vitePluginFakeServer({
|
|
245
|
+
logger: !isBuild,
|
|
246
|
+
include: "src/mock",
|
|
247
|
+
infixName: false,
|
|
248
|
+
enableProd: isBuild && VITE_BUILD_MOCK === "true"
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function createOpenAPI(options) {
|
|
253
|
+
return OpenAPI(options || { enabled: false });
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function createUnocss() {
|
|
257
|
+
return Unocss();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function createVitePlugins(viteEnv, isBuild = false, config) {
|
|
399
261
|
const vitePlugins = [
|
|
400
262
|
vue(),
|
|
401
263
|
vueJsx(),
|
|
402
|
-
|
|
403
|
-
modernPolyfills: [
|
|
404
|
-
"es.array.at",
|
|
405
|
-
"es.array.find-last"
|
|
406
|
-
],
|
|
407
|
-
additionalLegacyPolyfills: ["abort-controller/polyfill"]
|
|
408
|
-
}),
|
|
264
|
+
createLegacy(viteEnv),
|
|
409
265
|
createAutoImport(),
|
|
410
266
|
createComponents(),
|
|
411
267
|
createUnocss(),
|
|
412
|
-
createSvgIcon(isBuild),
|
|
413
268
|
createIcons(),
|
|
414
|
-
createI18n(),
|
|
415
269
|
createMock(viteEnv, isBuild),
|
|
416
|
-
createBanner(),
|
|
417
|
-
createPreprocessor(),
|
|
418
|
-
// createZip(),
|
|
419
|
-
createConsole(),
|
|
420
270
|
createInspector(viteEnv),
|
|
421
|
-
createOpenAPI(),
|
|
422
|
-
// createConfig(),
|
|
271
|
+
createOpenAPI(config.openapi),
|
|
423
272
|
appInfo()
|
|
424
273
|
];
|
|
425
274
|
const buildPlugins = () => [
|
|
@@ -431,11 +280,9 @@ function createVitePlugins(viteEnv, isBuild = false) {
|
|
|
431
280
|
return vitePlugins.filter(Boolean);
|
|
432
281
|
}
|
|
433
282
|
|
|
434
|
-
function
|
|
435
|
-
return
|
|
436
|
-
const root =
|
|
437
|
-
const pathResolve = (pathname) => resolve$1(root, ".", pathname);
|
|
438
|
-
const __SYSTEM_INFO__ = await createDefineSystemInfo(root);
|
|
283
|
+
function createDefaultAppConfig(config) {
|
|
284
|
+
return ({ mode, command }) => {
|
|
285
|
+
const root = cwd();
|
|
439
286
|
const isBuild = command === "build";
|
|
440
287
|
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
441
288
|
const env = loadEnv(mode, root);
|
|
@@ -447,46 +294,22 @@ function defineConfig(defineOptions = {}) {
|
|
|
447
294
|
open: true,
|
|
448
295
|
host: true,
|
|
449
296
|
proxy: serverProxy,
|
|
450
|
-
watch: {
|
|
451
|
-
ignored: ["!**/node_modules/@pubinfo/themes/src/system/**/*"]
|
|
452
|
-
},
|
|
453
297
|
warmup: {
|
|
454
298
|
clientFiles: [
|
|
455
|
-
"./index.html"
|
|
456
|
-
"./src/{layouts,components}/*",
|
|
457
|
-
"./src/locales/**/*"
|
|
299
|
+
"./index.html"
|
|
458
300
|
]
|
|
459
301
|
}
|
|
460
302
|
},
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
{
|
|
468
|
-
find: /#\//,
|
|
469
|
-
replacement: `${pathResolve("types")}/`
|
|
470
|
-
}
|
|
303
|
+
// To fix some dev problems
|
|
304
|
+
optimizeDeps: {
|
|
305
|
+
exclude: [
|
|
306
|
+
"pubinfo",
|
|
307
|
+
"@pubinfo/core",
|
|
308
|
+
"alova"
|
|
471
309
|
]
|
|
472
310
|
},
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
// ],
|
|
485
|
-
esbuildOptions: {
|
|
486
|
-
plugins: [
|
|
487
|
-
cleanse()
|
|
488
|
-
]
|
|
489
|
-
}
|
|
311
|
+
resolve: {
|
|
312
|
+
alias: alias(root)
|
|
490
313
|
},
|
|
491
314
|
build: {
|
|
492
315
|
outDir: mode === "production" ? "dist" : `dist-${mode}`,
|
|
@@ -495,28 +318,72 @@ function defineConfig(defineOptions = {}) {
|
|
|
495
318
|
chunkSizeWarningLimit: 2e3,
|
|
496
319
|
rollupOptions: {
|
|
497
320
|
output: {
|
|
498
|
-
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
// antd: ['ant-design-vue', '@ant-design/icons-vue'],
|
|
503
|
-
// lottie: ['lottie-web'],
|
|
504
|
-
// },
|
|
321
|
+
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`,
|
|
322
|
+
manualChunks: {
|
|
323
|
+
pubinfo: ["pubinfo"]
|
|
324
|
+
}
|
|
505
325
|
}
|
|
506
326
|
}
|
|
507
327
|
},
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
328
|
+
plugins: createVitePlugins(env, isBuild, config)
|
|
329
|
+
};
|
|
330
|
+
return applicationConfig;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function createDefaultModuleConfig(config) {
|
|
335
|
+
return ({ mode, command }) => {
|
|
336
|
+
const root = cwd();
|
|
337
|
+
const isBuild = command === "build";
|
|
338
|
+
const env = loadEnv(mode, root);
|
|
339
|
+
const applicationConfig = {
|
|
340
|
+
// To fix some dev problems
|
|
341
|
+
optimizeDeps: {
|
|
342
|
+
exclude: [
|
|
343
|
+
"pubinfo",
|
|
344
|
+
"@pubinfo/core",
|
|
345
|
+
"alova"
|
|
346
|
+
]
|
|
512
347
|
},
|
|
513
|
-
|
|
348
|
+
resolve: {
|
|
349
|
+
alias: alias(root)
|
|
350
|
+
},
|
|
351
|
+
build: {
|
|
352
|
+
rollupOptions: {
|
|
353
|
+
external: [
|
|
354
|
+
"vue",
|
|
355
|
+
"vue-router",
|
|
356
|
+
"pinia",
|
|
357
|
+
"unocss"
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
plugins: createVitePlugins(env, isBuild, config)
|
|
514
362
|
};
|
|
363
|
+
return applicationConfig;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function definePubinfoConfig(config) {
|
|
368
|
+
return {
|
|
369
|
+
...config,
|
|
370
|
+
vite: mergeViteConfig(createDefaultAppConfig(config), config)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function defineModuleConfig(config) {
|
|
374
|
+
return {
|
|
375
|
+
...config,
|
|
376
|
+
vite: mergeViteConfig(createDefaultModuleConfig(config), config)
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function mergeViteConfig(defaultOptions, config = {}) {
|
|
380
|
+
const { vite: viteOptions = {} } = config;
|
|
381
|
+
return defineConfig(({ mode, command }) => {
|
|
515
382
|
return mergeConfig(
|
|
516
|
-
|
|
517
|
-
typeof
|
|
383
|
+
defaultOptions({ mode, command }),
|
|
384
|
+
typeof viteOptions === "function" ? viteOptions({ mode, command }) : viteOptions
|
|
518
385
|
);
|
|
519
386
|
});
|
|
520
387
|
}
|
|
521
388
|
|
|
522
|
-
export {
|
|
389
|
+
export { defineModuleConfig, definePubinfoConfig };
|
package/package.json
CHANGED
|
@@ -1,62 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "2.0.0-beta.10",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"
|
|
8
|
+
"default": "./dist/index.mjs"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"main": "./dist/index.mjs",
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
12
13
|
"types": "./dist/index.d.ts",
|
|
13
14
|
"files": [
|
|
14
15
|
"dist"
|
|
15
16
|
],
|
|
16
17
|
"peerDependencies": {
|
|
17
|
-
"
|
|
18
|
-
"vue": "
|
|
19
|
-
"vue-i18n": ">=9.0.0"
|
|
18
|
+
"vue": "^3.5.13",
|
|
19
|
+
"vue-i18n": "^10.0.5"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@vitejs/plugin-
|
|
25
|
-
"@vitejs/plugin-vue": "^
|
|
26
|
-
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
22
|
+
"@pubinfo/unplugin-openapi": "^0.8.4",
|
|
23
|
+
"@vitejs/plugin-legacy": "^6.0.2",
|
|
24
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
25
|
+
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
27
26
|
"abort-controller": "^3.0.0",
|
|
28
27
|
"boxen": "^8.0.1",
|
|
29
|
-
"chalk": "^5.
|
|
30
|
-
"consola": "^3.
|
|
31
|
-
"
|
|
32
|
-
"fast-glob": "^3.3.2",
|
|
33
|
-
"fs-extra": "^11.2.0",
|
|
28
|
+
"chalk": "^5.4.1",
|
|
29
|
+
"consola": "^3.4.0",
|
|
30
|
+
"fs-extra": "^11.3.0",
|
|
34
31
|
"jszip": "^3.10.1",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"unplugin-
|
|
39
|
-
"unplugin-
|
|
40
|
-
"
|
|
41
|
-
"unplugin-vue-components": "^0.27.4",
|
|
42
|
-
"vite-plugin-banner": "^0.7.1",
|
|
32
|
+
"terser": "^5.39.0",
|
|
33
|
+
"unocss": "^65.5.0",
|
|
34
|
+
"unplugin-auto-import": "^19.1.1",
|
|
35
|
+
"unplugin-icons": "^22.1.0",
|
|
36
|
+
"unplugin-vue-components": "^28.4.1",
|
|
37
|
+
"vite": "^6.2.0",
|
|
43
38
|
"vite-plugin-compression": "^0.5.1",
|
|
44
|
-
"vite-plugin-env-runtime": "^0.3.
|
|
45
|
-
"vite-plugin-fake-server": "^2.
|
|
46
|
-
"vite-plugin-
|
|
47
|
-
"vite-plugin-svg-icons": "^2.0.1",
|
|
48
|
-
"vite-plugin-vue-devtools": "^7.3.9"
|
|
39
|
+
"vite-plugin-env-runtime": "^0.3.6",
|
|
40
|
+
"vite-plugin-fake-server": "^2.2.0",
|
|
41
|
+
"vite-plugin-vue-devtools": "^7.7.2"
|
|
49
42
|
},
|
|
50
43
|
"devDependencies": {
|
|
51
44
|
"@types/fs-extra": "^11.0.4",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"vue
|
|
45
|
+
"@types/node": "^22.13.9",
|
|
46
|
+
"unbuild": "^3.5.0",
|
|
47
|
+
"vue": "^3.5.13",
|
|
48
|
+
"vue-i18n": "^10.0.5"
|
|
55
49
|
},
|
|
56
50
|
"scripts": {
|
|
57
|
-
"clean": "pnpm rimraf node_modules dist .turbo",
|
|
58
|
-
"build": "unbuild",
|
|
59
51
|
"stub": "unbuild --stub",
|
|
60
|
-
"
|
|
52
|
+
"build": "unbuild"
|
|
61
53
|
}
|
|
62
54
|
}
|