@quiteer/vite 0.0.6 → 0.1.0
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/bin/qvite.mjs +74 -7
- package/dist/index.d.mts +12 -8
- package/dist/index.mjs +6 -5906
- package/package.json +5 -5
- package/dist/bin/context-Db5EuGKU-B3vpL0eS.mjs +0 -24
- package/dist/bin/dist-BmyFpZwL.mjs +0 -7
- package/dist/bin/dist-BniM_x9D.mjs +0 -5256
- package/dist/bin/dist-Bvgk2hb8.mjs +0 -187
- package/dist/bin/dist-CjNY_432.mjs +0 -473
- package/dist/bin/dist-DQNZhGEj.mjs +0 -10562
- package/dist/bin/esm-CQYKr9An.mjs +0 -1557
- package/dist/bin/experimental-index-DiVJ_oZg.mjs +0 -71
- package/dist/bin/resolver-DymnxKPB-UI_9xIg2.mjs +0 -16
- package/dist/bin/src-BwxUhqZU-Dr1MNcyS.mjs +0 -5046
- package/dist/bin/tsc-TmK__neM.mjs +0 -406
package/dist/bin/qvite.mjs
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
import { cac } from "cac";
|
|
3
3
|
import { build, createServer, loadEnv, mergeConfig } from "vite";
|
|
4
4
|
import { PersistentStore, deepMerge } from "@quiteer/utils";
|
|
5
|
-
import { Progress, UnoCSS, Vue, VueDevTools, VueJsx, bootstrapEnv, envConfigPlugin, fileChangeLoggerPlugin, mockRouterPlugin, removeConsolePlugin, virtualHtmlPlugin } from "@quiteer/vite-plugins";
|
|
5
|
+
import { AutoImport, Components, Icons, IconsResolver, NaiveUiResolver, Progress, UnoCSS, Vue, VueDevTools, VueJsx, bootstrapEnv, createSvgIconsPlugin, envConfigPlugin, fileChangeLoggerPlugin, mockRouterPlugin, removeConsolePlugin, virtualHtmlPlugin } from "@quiteer/vite-plugins";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { cwd } from "node:process";
|
|
8
|
-
import { join } from "node:path";
|
|
8
|
+
import path, { join } from "node:path";
|
|
9
9
|
import { isFunction } from "@quiteer/is";
|
|
10
10
|
import { parserConfig } from "@quiteer/parser-config";
|
|
11
11
|
import { pathExists } from "fs-extra";
|
|
12
|
+
import { setTimeout } from "node:timers/promises";
|
|
12
13
|
import { getPortPromise } from "portfinder";
|
|
13
14
|
|
|
14
15
|
//#region package.json
|
|
15
|
-
var version = "0.0
|
|
16
|
+
var version = "0.1.0";
|
|
16
17
|
|
|
17
18
|
//#endregion
|
|
18
19
|
//#region src/defaults.ts
|
|
@@ -25,7 +26,29 @@ const defaultOptions = {
|
|
|
25
26
|
Progress: [{}],
|
|
26
27
|
FileChangeLogger: false,
|
|
27
28
|
RemoveConsole: false,
|
|
28
|
-
MockRouter: false
|
|
29
|
+
MockRouter: false,
|
|
30
|
+
Icons: false,
|
|
31
|
+
SvgIcons: false,
|
|
32
|
+
AutoImport: [{ imports: [
|
|
33
|
+
"vue",
|
|
34
|
+
"vue-router",
|
|
35
|
+
{ "naive-ui": [
|
|
36
|
+
"useDialog",
|
|
37
|
+
"useMessage",
|
|
38
|
+
"useNotification",
|
|
39
|
+
"useLoadingBar"
|
|
40
|
+
] }
|
|
41
|
+
] }],
|
|
42
|
+
Components: [{
|
|
43
|
+
types: [{
|
|
44
|
+
from: "vue-router",
|
|
45
|
+
names: ["RouterLink", "RouterView"]
|
|
46
|
+
}],
|
|
47
|
+
resolvers: [NaiveUiResolver(), IconsResolver({
|
|
48
|
+
customCollections: "local",
|
|
49
|
+
componentPrefix: "icon-loacl"
|
|
50
|
+
})]
|
|
51
|
+
}]
|
|
29
52
|
},
|
|
30
53
|
html: {},
|
|
31
54
|
env: {
|
|
@@ -52,7 +75,11 @@ var plugins_default = {
|
|
|
52
75
|
Vue,
|
|
53
76
|
VueDevTools,
|
|
54
77
|
VueJsx,
|
|
55
|
-
UnoCSS
|
|
78
|
+
UnoCSS,
|
|
79
|
+
Components,
|
|
80
|
+
SvgIcons: createSvgIconsPlugin,
|
|
81
|
+
Icons,
|
|
82
|
+
AutoImport
|
|
56
83
|
};
|
|
57
84
|
|
|
58
85
|
//#endregion
|
|
@@ -124,7 +151,7 @@ async function toViteInlineConfig(config) {
|
|
|
124
151
|
async function build$1(options) {
|
|
125
152
|
const normalized = await normalizeConfig(options);
|
|
126
153
|
if (normalized.tsdown && (Array.isArray(normalized.tsdown) && normalized.tsdown.length > 0 || !Array.isArray(normalized.tsdown) && Object.keys(normalized.tsdown).length > 0)) {
|
|
127
|
-
const { build: tsdownBuild } = await import("
|
|
154
|
+
const { build: tsdownBuild } = await import("tsdown");
|
|
128
155
|
await tsdownBuild(normalized.tsdown);
|
|
129
156
|
}
|
|
130
157
|
await build(await toViteInlineConfig(normalized));
|
|
@@ -191,6 +218,7 @@ async function getConfig(filePath) {
|
|
|
191
218
|
* @remarks
|
|
192
219
|
* - 若配置的 `port` 被占用,将自动选取下一个可用端口
|
|
193
220
|
* - 启动前执行一次 tsdown 构建,便于开发期产物可用
|
|
221
|
+
* - 监控 `qvite.config.*` 变更并自动重启开发服务器(防抖)
|
|
194
222
|
*
|
|
195
223
|
* @security
|
|
196
224
|
* 不暴露敏感信息,仅打印本地 URL
|
|
@@ -213,10 +241,49 @@ async function watch(options) {
|
|
|
213
241
|
await viteDevServer.listen(p);
|
|
214
242
|
viteDevServer.printUrls();
|
|
215
243
|
if (normalized.tsdown) {
|
|
216
|
-
const { build: tsdownBuild } = await import("
|
|
244
|
+
const { build: tsdownBuild } = await import("tsdown");
|
|
217
245
|
if (!Array.isArray(normalized.tsdown)) await tsdownBuild(normalized.tsdown);
|
|
218
246
|
else await Promise.all(normalized.tsdown.map(tsdownBuild));
|
|
219
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* 自动重启:监听 qvite 配置文件变更
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* - 使用 Vite 的内部 `chokidar` watcher,避免额外依赖
|
|
253
|
+
* - 统一监听多种后缀:`.ts`、`.mjs`、`.cjs`、`.js`、`.json`
|
|
254
|
+
* - 采用简单防抖,避免短时间内多次触发
|
|
255
|
+
*/
|
|
256
|
+
const root$1 = store.get("root");
|
|
257
|
+
const configBase = store.get("config") || "qvite.config.ts";
|
|
258
|
+
const candidates = [
|
|
259
|
+
"ts",
|
|
260
|
+
"mjs",
|
|
261
|
+
"cjs",
|
|
262
|
+
"js",
|
|
263
|
+
"json"
|
|
264
|
+
].map((s) => path.join(root$1, `qvite.config.${s}`));
|
|
265
|
+
const customPath = path.isAbsolute(configBase) ? configBase : path.join(root$1, configBase);
|
|
266
|
+
const watchList = Array.from(new Set([customPath, ...candidates]));
|
|
267
|
+
viteDevServer.watcher.add(watchList);
|
|
268
|
+
let pending = false;
|
|
269
|
+
const restart = async () => {
|
|
270
|
+
if (pending) return;
|
|
271
|
+
pending = true;
|
|
272
|
+
await setTimeout(150);
|
|
273
|
+
try {
|
|
274
|
+
viteDevServer.config.logger.info(`[qvite] 检测到配置变更,正在重启开发服务器...`);
|
|
275
|
+
await viteDevServer.close();
|
|
276
|
+
await watch(await getConfig(store.get("config") || "qvite.config.ts"));
|
|
277
|
+
} catch (e) {
|
|
278
|
+
viteDevServer.config.logger.error(`[qvite] 重启失败:${e.message}`);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
viteDevServer.watcher.on("change", (changedPath) => {
|
|
282
|
+
if (watchList.includes(changedPath)) restart();
|
|
283
|
+
});
|
|
284
|
+
viteDevServer.watcher.on("unlink", (unlinkedPath) => {
|
|
285
|
+
if (watchList.includes(unlinkedPath)) restart();
|
|
286
|
+
});
|
|
220
287
|
}
|
|
221
288
|
|
|
222
289
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserConfig, defineConfig as defineConfig$1 } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { UserConfig, defineConfig as defineConfig$1 } from "tsdown";
|
|
2
|
+
import { UserConfig as UserConfig$1, defineConfig as defineConfig$2 } from "vite";
|
|
3
|
+
import { AutoImport, Components, EnvConfig, EnvConfigPluginOptions, FileSystemIconLoader, Icons, IconsResolver, NaiveUiResolver, Progress, UnoCSS, VirtualHtmlOptions, Vue, VueDevTools, VueJsx, createSvgIconsPlugin, fileChangeLoggerPlugin, mockRouterPlugin, removeConsolePlugin } from "@quiteer/vite-plugins";
|
|
4
4
|
|
|
5
5
|
//#region src/typings.d.ts
|
|
6
6
|
type PluginOptions<T extends (...args: any) => any> = boolean | Parameters<T>;
|
|
@@ -13,10 +13,14 @@ interface QvitePlugins {
|
|
|
13
13
|
RemoveConsole?: PluginOptions<typeof removeConsolePlugin>;
|
|
14
14
|
MockRouter?: PluginOptions<typeof mockRouterPlugin>;
|
|
15
15
|
FileChangeLogger?: PluginOptions<typeof fileChangeLoggerPlugin>;
|
|
16
|
+
Components?: PluginOptions<typeof Components>;
|
|
17
|
+
SvgIcons?: PluginOptions<typeof createSvgIconsPlugin>;
|
|
18
|
+
Icons?: PluginOptions<typeof Icons>;
|
|
19
|
+
AutoImport?: PluginOptions<typeof AutoImport>;
|
|
16
20
|
}
|
|
17
21
|
interface QviteConfig {
|
|
18
|
-
vite?: UserConfig;
|
|
19
|
-
tsdown?: UserConfig
|
|
22
|
+
vite?: UserConfig$1;
|
|
23
|
+
tsdown?: UserConfig | UserConfig[];
|
|
20
24
|
plugins?: QvitePlugins;
|
|
21
25
|
html?: VirtualHtmlOptions;
|
|
22
26
|
env?: EnvConfigPluginOptions;
|
|
@@ -87,7 +91,7 @@ declare function defineConfig(config: QviteConfigExport): QviteConfigExport;
|
|
|
87
91
|
* @performance
|
|
88
92
|
* 常量时间委托,无额外开销
|
|
89
93
|
*/
|
|
90
|
-
declare function defineViteConfig(config: Parameters<typeof defineConfig$
|
|
94
|
+
declare function defineViteConfig(config: Parameters<typeof defineConfig$2>[0]): ReturnType<typeof defineConfig$2>;
|
|
91
95
|
/**
|
|
92
96
|
* 暴露 tsdown 的 `defineConfig`(类型辅助包装)
|
|
93
97
|
*
|
|
@@ -113,6 +117,6 @@ declare function defineViteConfig(config: Parameters<typeof defineConfig$1>[0]):
|
|
|
113
117
|
* @performance
|
|
114
118
|
* 常量时间委托,无额外开销
|
|
115
119
|
*/
|
|
116
|
-
declare function defineTsdownConfig(config: Parameters<typeof defineConfig$
|
|
120
|
+
declare function defineTsdownConfig(config: Parameters<typeof defineConfig$1>[0]): ReturnType<typeof defineConfig$1>;
|
|
117
121
|
//#endregion
|
|
118
|
-
export { Command, ConfigEnv, type EnvConfig, Mode, PluginOptions, QviteConfig, QviteConfigExport, QviteConfigFn, QviteConfigFnObject, QviteConfigFnPromise, QvitePlugins, defineConfig, defineTsdownConfig, defineViteConfig };
|
|
122
|
+
export { Command, ConfigEnv, type EnvConfig, FileSystemIconLoader, IconsResolver, Mode, NaiveUiResolver, PluginOptions, QviteConfig, QviteConfigExport, QviteConfigFn, QviteConfigFnObject, QviteConfigFnPromise, QvitePlugins, defineConfig, defineTsdownConfig, defineViteConfig };
|