@pubinfo/vite 2.0.0-beta.3 → 2.0.0-beta.31

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 CHANGED
@@ -2,6 +2,7 @@ import * as _pubinfo_unplugin_openapi from '@pubinfo/unplugin-openapi';
2
2
  import { Options } from '@pubinfo/unplugin-openapi';
3
3
  import { UserConfig, UserConfigFnObject } from 'vite';
4
4
  export * from 'vite';
5
+ export * from 'vite-plugin-fake-server/client';
5
6
 
6
7
  interface PubinfoConfig {
7
8
  /** `vite` */
@@ -25,4 +26,4 @@ declare function defineModuleConfig(config: PubinfoConfig): {
25
26
  openapi?: _pubinfo_unplugin_openapi.Options;
26
27
  };
27
28
 
28
- export { defineModuleConfig, definePubinfoConfig };
29
+ export { type PubinfoConfig, defineModuleConfig, definePubinfoConfig };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as _pubinfo_unplugin_openapi from '@pubinfo/unplugin-openapi';
2
2
  import { Options } from '@pubinfo/unplugin-openapi';
3
3
  import { UserConfig, UserConfigFnObject } from 'vite';
4
4
  export * from 'vite';
5
+ export * from 'vite-plugin-fake-server/client';
5
6
 
6
7
  interface PubinfoConfig {
7
8
  /** `vite` */
@@ -25,4 +26,4 @@ declare function defineModuleConfig(config: PubinfoConfig): {
25
26
  openapi?: _pubinfo_unplugin_openapi.Options;
26
27
  };
27
28
 
28
- export { defineModuleConfig, definePubinfoConfig };
29
+ export { type PubinfoConfig, defineModuleConfig, definePubinfoConfig };
package/dist/index.mjs CHANGED
@@ -20,6 +20,7 @@ import { existsSync } from 'node:fs';
20
20
  import { vitePluginFakeServer } from 'vite-plugin-fake-server';
21
21
  import OpenAPI from '@pubinfo/unplugin-openapi/vite';
22
22
  import Unocss from 'unocss/vite';
23
+ export * from 'vite-plugin-fake-server/client';
23
24
 
24
25
  function alias(root) {
25
26
  const resolvePath = (name) => join(root, name);
@@ -303,7 +304,8 @@ function createDefaultAppConfig(config) {
303
304
  optimizeDeps: {
304
305
  exclude: [
305
306
  "pubinfo",
306
- "@pubinfo/core"
307
+ "@pubinfo/core",
308
+ "alova"
307
309
  ]
308
310
  },
309
311
  resolve: {
@@ -316,7 +318,10 @@ function createDefaultAppConfig(config) {
316
318
  chunkSizeWarningLimit: 2e3,
317
319
  rollupOptions: {
318
320
  output: {
319
- entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`
321
+ entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`,
322
+ manualChunks: {
323
+ pubinfo: ["pubinfo"]
324
+ }
320
325
  }
321
326
  }
322
327
  },
@@ -336,7 +341,8 @@ function createDefaultModuleConfig(config) {
336
341
  optimizeDeps: {
337
342
  exclude: [
338
343
  "pubinfo",
339
- "@pubinfo/core"
344
+ "@pubinfo/core",
345
+ "alova"
340
346
  ]
341
347
  },
342
348
  resolve: {
package/package.json CHANGED
@@ -1,52 +1,51 @@
1
1
  {
2
2
  "name": "@pubinfo/vite",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.3",
4
+ "version": "2.0.0-beta.31",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
8
- "import": "./dist/index.mjs",
9
- "require": "./dist/index.cjs"
8
+ "default": "./dist/index.mjs"
10
9
  }
11
10
  },
12
- "main": "./dist/index.cjs",
11
+ "main": "./dist/index.mjs",
13
12
  "module": "./dist/index.mjs",
14
13
  "types": "./dist/index.d.ts",
15
14
  "files": [
16
15
  "dist"
17
16
  ],
18
17
  "peerDependencies": {
19
- "vue": "^3.5.12",
20
- "vue-i18n": "^10.0.4"
18
+ "vue": "^3.5.16",
19
+ "vue-i18n": "^10.0.7"
21
20
  },
22
21
  "dependencies": {
23
22
  "@pubinfo/unplugin-openapi": "^0.8.4",
24
- "@vitejs/plugin-legacy": "^6.0.2",
25
- "@vitejs/plugin-vue": "^5.2.1",
26
- "@vitejs/plugin-vue-jsx": "^4.1.1",
23
+ "@vitejs/plugin-legacy": "^6.1.1",
24
+ "@vitejs/plugin-vue": "^5.2.4",
25
+ "@vitejs/plugin-vue-jsx": "^4.2.0",
27
26
  "abort-controller": "^3.0.0",
28
27
  "boxen": "^8.0.1",
29
28
  "chalk": "^5.4.1",
30
- "consola": "^3.4.0",
29
+ "consola": "^3.4.2",
31
30
  "fs-extra": "^11.3.0",
32
31
  "jszip": "^3.10.1",
33
- "terser": "^5.39.0",
32
+ "terser": "^5.40.0",
34
33
  "unocss": "^65.5.0",
35
- "unplugin-auto-import": "^19.1.1",
34
+ "unplugin-auto-import": "^19.3.0",
36
35
  "unplugin-icons": "^22.1.0",
37
- "unplugin-vue-components": "^28.4.1",
38
- "vite": "^6.2.0",
36
+ "unplugin-vue-components": "^28.7.0",
37
+ "vite": "^6.3.5",
39
38
  "vite-plugin-compression": "^0.5.1",
40
39
  "vite-plugin-env-runtime": "^0.3.6",
41
40
  "vite-plugin-fake-server": "^2.2.0",
42
- "vite-plugin-vue-devtools": "^7.7.2"
41
+ "vite-plugin-vue-devtools": "^7.7.6"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@types/fs-extra": "^11.0.4",
46
- "@types/node": "^22.13.9",
45
+ "@types/node": "^22.15.27",
47
46
  "unbuild": "^3.5.0",
48
- "vue": "^3.5.13",
49
- "vue-i18n": "^10.0.5"
47
+ "vue": "^3.5.16",
48
+ "vue-i18n": "^10.0.7"
50
49
  },
51
50
  "scripts": {
52
51
  "stub": "unbuild --stub",
package/dist/index.cjs DELETED
@@ -1,413 +0,0 @@
1
- 'use strict';
2
-
3
- const vite = require('vite');
4
- const node_process = require('node:process');
5
- const chalk = require('chalk');
6
- const consola = require('consola');
7
- const node_module = require('node:module');
8
- const node_path = require('node:path');
9
- const vue = require('@vitejs/plugin-vue');
10
- const vueJsx = require('@vitejs/plugin-vue-jsx');
11
- const autoImport = require('unplugin-auto-import/vite');
12
- const IconsResolver = require('unplugin-icons/resolver');
13
- const resolvers = require('unplugin-vue-components/resolvers');
14
- const components = require('unplugin-vue-components/vite');
15
- const compression = require('vite-plugin-compression');
16
- const Icons = require('unplugin-icons/vite');
17
- const boxen = require('boxen');
18
- const VueDevTools = require('vite-plugin-vue-devtools');
19
- const vueLegacy = require('@vitejs/plugin-legacy');
20
- const node_fs = require('node:fs');
21
- const vitePluginFakeServer = require('vite-plugin-fake-server');
22
- const OpenAPI = require('@pubinfo/unplugin-openapi/vite');
23
- const Unocss = require('unocss/vite');
24
-
25
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
26
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
27
-
28
- const chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
29
- const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
30
- const vue__default = /*#__PURE__*/_interopDefaultCompat(vue);
31
- const vueJsx__default = /*#__PURE__*/_interopDefaultCompat(vueJsx);
32
- const autoImport__default = /*#__PURE__*/_interopDefaultCompat(autoImport);
33
- const IconsResolver__default = /*#__PURE__*/_interopDefaultCompat(IconsResolver);
34
- const components__default = /*#__PURE__*/_interopDefaultCompat(components);
35
- const compression__default = /*#__PURE__*/_interopDefaultCompat(compression);
36
- const Icons__default = /*#__PURE__*/_interopDefaultCompat(Icons);
37
- const boxen__default = /*#__PURE__*/_interopDefaultCompat(boxen);
38
- const VueDevTools__default = /*#__PURE__*/_interopDefaultCompat(VueDevTools);
39
- const vueLegacy__default = /*#__PURE__*/_interopDefaultCompat(vueLegacy);
40
- const OpenAPI__default = /*#__PURE__*/_interopDefaultCompat(OpenAPI);
41
- const Unocss__default = /*#__PURE__*/_interopDefaultCompat(Unocss);
42
-
43
- function alias(root) {
44
- const resolvePath = (name) => node_path.join(root, name);
45
- const resolveDeps = (name, path) => node_path.join(node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).resolve(name), path);
46
- return {
47
- "@": resolvePath("src"),
48
- "#": resolvePath("types"),
49
- // 提供路径别名给 @pubinfo/core 直接调用项目中的文件
50
- "pubinfo:project": resolvePath("src"),
51
- // 显示的列出导出的目录
52
- // '.pubinfo': resolvePath('.pubinfo/'),
53
- // '.pubinfo/api': resolvePath('.pubinfo/api/'),
54
- // '.pubinfo/assets': resolvePath('.pubinfo/assets/'),
55
- // '.pubinfo/config': resolvePath('.pubinfo/config/'),
56
- // '.pubinfo/directives': resolvePath('.pubinfo/directives/'),
57
- // '.pubinfo/layout': resolvePath('.pubinfo/layout/'),
58
- // '.pubinfo/locales': resolvePath('.pubinfo/locales/'),
59
- // '.pubinfo/router': resolvePath('.pubinfo/router/'),
60
- // '.pubinfo/store': resolvePath('.pubinfo/store/'),
61
- // '.pubinfo/styles': resolvePath('.pubinfo/styles/'),
62
- // '.pubinfo/themes': resolvePath('.pubinfo/themes/'),
63
- // '.pubinfo/types': resolvePath('.pubinfo/types/'),
64
- // '.pubinfo/utils': resolvePath('.pubinfo/utils/'),
65
- // '.pubinfo/vue': resolvePath('.pubinfo/vue/'),
66
- // deps
67
- "vue": resolveDeps("vue", "../"),
68
- "vue-router": resolveDeps("vue-router", "../"),
69
- "pinia": resolveDeps("pinia", "../"),
70
- "unocss": resolveDeps("unocss", "../")
71
- };
72
- }
73
-
74
- function getServerProxy(env, isProxy) {
75
- if (!isProxy) {
76
- return {};
77
- }
78
- const targetPrefix = "VITE_APP_API_";
79
- const proxyKey = Object.keys(env).filter((key) => key.startsWith(targetPrefix));
80
- const serverProxy = {};
81
- for (const envKey of proxyKey) {
82
- const url = env[envKey];
83
- const { pathname } = new URL(url);
84
- const pk = `${pathname}/proxy`;
85
- if (pk in serverProxy) {
86
- consola__default.error(`The proxy key ${chalk__default.bold.redBright(envKey)} \u279C ${chalk__default.bold.yellowBright(url)} already exists`);
87
- } else {
88
- serverProxy[pk] = {
89
- target: url,
90
- changeOrigin: true,
91
- rewrite: (path) => path.replace(pk, ""),
92
- secure: false
93
- };
94
- }
95
- }
96
- return serverProxy;
97
- }
98
-
99
- function createAutoImport() {
100
- return autoImport__default({
101
- imports: [
102
- "vue",
103
- "vue-router",
104
- // 'vue-i18n',
105
- "pinia",
106
- {
107
- pubinfo: [
108
- "useAuth"
109
- ]
110
- }
111
- ],
112
- // 解决代码混淆后出现的h和vue导入的h变量命名重复的问题
113
- ignore: ["h"],
114
- dts: "./types/auto-imports.d.ts",
115
- dirs: [
116
- "./src/composables/**/*"
117
- ],
118
- resolvers: [
119
- resolvers.AntDesignVueResolver(),
120
- IconsResolver__default({
121
- prefix: "i"
122
- })
123
- ]
124
- });
125
- }
126
-
127
- function createComponents() {
128
- return components__default({
129
- dirs: [
130
- "src/components"
131
- ],
132
- directives: true,
133
- include: [/\.vue$/, /\.vue\?vue/, /\.tsx$/],
134
- resolvers: [
135
- IconsResolver__default(),
136
- resolvers.AntDesignVueResolver({
137
- resolveIcons: true,
138
- importStyle: false
139
- }),
140
- {
141
- type: "component",
142
- resolve(name) {
143
- const components2 = [
144
- "PubinfoApp",
145
- "PubinfoProvider",
146
- "PubinfoIcon"
147
- ];
148
- if (components2.includes(name)) {
149
- return { name, from: "pubinfo" };
150
- }
151
- }
152
- }
153
- ],
154
- dts: "./types/components.d.ts"
155
- });
156
- }
157
-
158
- function createCompression(env) {
159
- const { VITE_BUILD_COMPRESS } = env;
160
- const compressList = VITE_BUILD_COMPRESS?.split(",") ?? [];
161
- const plugin = [];
162
- if (compressList.includes("gzip")) {
163
- plugin.push(
164
- compression__default({
165
- ext: ".gz",
166
- deleteOriginFile: false
167
- })
168
- );
169
- }
170
- if (compressList.includes("brotli")) {
171
- plugin.push(
172
- compression__default({
173
- ext: ".br",
174
- algorithm: "brotliCompress",
175
- deleteOriginFile: false
176
- })
177
- );
178
- }
179
- return plugin;
180
- }
181
-
182
- function createIcons() {
183
- return Icons__default({
184
- autoInstall: false
185
- });
186
- }
187
-
188
- class Ctx {
189
- options;
190
- setOptions(options) {
191
- this.options = options;
192
- }
193
- async createInfo() {
194
- console.log(
195
- boxen__default(
196
- `\u6B22\u8FCE\u4F7F\u7528${chalk__default.bold.greenBright(" \u6280\u672F\u5E95\u5EA7\u7BA1\u7406\u7CFB\u7EDF ")}
197
-
198
- ${chalk__default.green("\u4F7F\u7528\u6587\u6863\u5730\u5740")} ${chalk__default.green("\u279C")} https://134.108.39.195:9090/docs`,
199
- {
200
- padding: 1,
201
- margin: 1,
202
- align: "center",
203
- borderColor: "yellowBright",
204
- borderStyle: "round"
205
- }
206
- )
207
- );
208
- }
209
- }
210
- const ctx = new Ctx();
211
- function appInfo() {
212
- return {
213
- name: "appInfo",
214
- apply: "serve",
215
- enforce: "pre",
216
- configResolved(configuration) {
217
- const root = configuration.root;
218
- ctx.setOptions({
219
- root
220
- });
221
- },
222
- async buildStart() {
223
- ctx.createInfo();
224
- },
225
- configureServer(server) {
226
- const _printUrls = server.printUrls;
227
- server.printUrls = () => {
228
- console.log(` ${chalk__default.green("\u279C")} ${chalk__default.bold.bgBlueBright(` PUBINFO `)}${chalk__default.bold.bgYellowBright(` \u524D\u7AEF\u57FA\u7840\u6846\u67B6 `)}`);
229
- _printUrls();
230
- };
231
- }
232
- };
233
- }
234
-
235
- function createInspector(env) {
236
- const { VITE_APP_INSPECTOR } = env;
237
- if (VITE_APP_INSPECTOR && VITE_APP_INSPECTOR === "true") {
238
- return VueDevTools__default();
239
- } else {
240
- return null;
241
- }
242
- }
243
-
244
- function createLegacy(env) {
245
- if (env.VITE_BUILD_LEGACY !== "true") {
246
- return false;
247
- }
248
- return vueLegacy__default({
249
- modernPolyfills: [
250
- "es.array.at",
251
- "es.array.find-last"
252
- ],
253
- additionalLegacyPolyfills: ["abort-controller/polyfill"]
254
- });
255
- }
256
-
257
- function createMock(env, isBuild) {
258
- const { VITE_BUILD_MOCK } = env;
259
- if (!node_fs.existsSync(node_path.resolve(node_process.cwd(), "src/mock"))) {
260
- return;
261
- }
262
- return vitePluginFakeServer.vitePluginFakeServer({
263
- logger: !isBuild,
264
- include: "src/mock",
265
- infixName: false,
266
- enableProd: isBuild && VITE_BUILD_MOCK === "true"
267
- });
268
- }
269
-
270
- function createOpenAPI(options) {
271
- return OpenAPI__default(options || { enabled: false });
272
- }
273
-
274
- function createUnocss() {
275
- return Unocss__default();
276
- }
277
-
278
- function createVitePlugins(viteEnv, isBuild = false, config) {
279
- const vitePlugins = [
280
- vue__default(),
281
- vueJsx__default(),
282
- createLegacy(viteEnv),
283
- createAutoImport(),
284
- createComponents(),
285
- createUnocss(),
286
- createIcons(),
287
- createMock(viteEnv, isBuild),
288
- createInspector(viteEnv),
289
- createOpenAPI(config.openapi),
290
- appInfo()
291
- ];
292
- const buildPlugins = () => [
293
- ...createCompression(viteEnv)
294
- ];
295
- if (isBuild) {
296
- vitePlugins.push(...buildPlugins());
297
- }
298
- return vitePlugins.filter(Boolean);
299
- }
300
-
301
- function createDefaultAppConfig(config) {
302
- return ({ mode, command }) => {
303
- const root = node_process.cwd();
304
- const isBuild = command === "build";
305
- const timestamp = (/* @__PURE__ */ new Date()).getTime();
306
- const env = vite.loadEnv(mode, root);
307
- const { VITE_OPEN_PROXY, VITE_BUILD_SOURCEMAP } = env;
308
- const serverProxy = getServerProxy(env, !isBuild && VITE_OPEN_PROXY === "true");
309
- const applicationConfig = {
310
- base: "./",
311
- server: {
312
- open: true,
313
- host: true,
314
- proxy: serverProxy,
315
- warmup: {
316
- clientFiles: [
317
- "./index.html"
318
- ]
319
- }
320
- },
321
- // To fix some dev problems
322
- optimizeDeps: {
323
- exclude: [
324
- "pubinfo",
325
- "@pubinfo/core"
326
- ]
327
- },
328
- resolve: {
329
- alias: alias(root)
330
- },
331
- build: {
332
- outDir: mode === "production" ? "dist" : `dist-${mode}`,
333
- sourcemap: VITE_BUILD_SOURCEMAP === "true",
334
- reportCompressedSize: false,
335
- chunkSizeWarningLimit: 2e3,
336
- rollupOptions: {
337
- output: {
338
- entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`
339
- }
340
- }
341
- },
342
- plugins: createVitePlugins(env, isBuild, config)
343
- };
344
- return applicationConfig;
345
- };
346
- }
347
-
348
- function createDefaultModuleConfig(config) {
349
- return ({ mode, command }) => {
350
- const root = node_process.cwd();
351
- const isBuild = command === "build";
352
- const env = vite.loadEnv(mode, root);
353
- const applicationConfig = {
354
- // To fix some dev problems
355
- optimizeDeps: {
356
- exclude: [
357
- "pubinfo",
358
- "@pubinfo/core"
359
- ]
360
- },
361
- resolve: {
362
- alias: alias(root)
363
- },
364
- build: {
365
- rollupOptions: {
366
- external: [
367
- "vue",
368
- "vue-router",
369
- "pinia",
370
- "unocss"
371
- ]
372
- }
373
- },
374
- plugins: createVitePlugins(env, isBuild, config)
375
- };
376
- return applicationConfig;
377
- };
378
- }
379
-
380
- function definePubinfoConfig(config) {
381
- return {
382
- ...config,
383
- vite: mergeViteConfig(createDefaultAppConfig(config), config)
384
- };
385
- }
386
- function defineModuleConfig(config) {
387
- return {
388
- ...config,
389
- vite: mergeViteConfig(createDefaultModuleConfig(config), config)
390
- };
391
- }
392
- function mergeViteConfig(defaultOptions, config = {}) {
393
- const { vite: viteOptions = {} } = config;
394
- return vite.defineConfig(({ mode, command }) => {
395
- return vite.mergeConfig(
396
- defaultOptions({ mode, command }),
397
- typeof viteOptions === "function" ? viteOptions({ mode, command }) : viteOptions
398
- );
399
- });
400
- }
401
-
402
- exports.defineModuleConfig = defineModuleConfig;
403
- exports.definePubinfoConfig = definePubinfoConfig;
404
- Object.prototype.hasOwnProperty.call(vite, '__proto__') &&
405
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
406
- Object.defineProperty(exports, '__proto__', {
407
- enumerable: true,
408
- value: vite['__proto__']
409
- });
410
-
411
- Object.keys(vite).forEach(function (k) {
412
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = vite[k];
413
- });
package/dist/index.d.cts DELETED
@@ -1,28 +0,0 @@
1
- import * as _pubinfo_unplugin_openapi from '@pubinfo/unplugin-openapi';
2
- import { Options } from '@pubinfo/unplugin-openapi';
3
- import { UserConfig, UserConfigFnObject } from 'vite';
4
- export * from 'vite';
5
-
6
- interface PubinfoConfig {
7
- /** `vite` */
8
- vite?: UserConfig | UserConfigFnObject;
9
- /** `@pubinfo/unplugin-openapi` */
10
- openapi?: Options;
11
- }
12
-
13
- /**
14
- * 构建应用配置
15
- */
16
- declare function definePubinfoConfig(config: PubinfoConfig): {
17
- vite: UserConfigFnObject;
18
- openapi?: _pubinfo_unplugin_openapi.Options;
19
- };
20
- /**
21
- * 构建模块配置
22
- */
23
- declare function defineModuleConfig(config: PubinfoConfig): {
24
- vite: UserConfigFnObject;
25
- openapi?: _pubinfo_unplugin_openapi.Options;
26
- };
27
-
28
- export { defineModuleConfig, definePubinfoConfig };