@quiteer/vite 0.1.7 → 0.1.9
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 +33 -15
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/uno.config.ts +17 -1
package/dist/bin/qvite.mjs
CHANGED
|
@@ -3,8 +3,9 @@ import { cac } from "cac";
|
|
|
3
3
|
import { build, createServer, loadEnv, mergeConfig } from "vite";
|
|
4
4
|
import UnoCSS from "@quiteer/unocss";
|
|
5
5
|
import { PersistentStore, deepMerge } from "@quiteer/utils";
|
|
6
|
-
import {
|
|
6
|
+
import { bootstrapEnv, envConfigPlugin, fileChangeLoggerPlugin, mockRouterPlugin, removeConsolePlugin, virtualHtmlPlugin } from "@quiteer/vite-plugins";
|
|
7
7
|
import path, { join, resolve } from "node:path";
|
|
8
|
+
import { AutoImport, Components, FileSystemIconLoader, Icons, IconsResolver, NaiveUiResolver, Progress, Vue, VueDevTools, VueJsx, createSvgIconsPlugin } from "@quiteer/vite-plugins/plugins";
|
|
8
9
|
import { cwd } from "node:process";
|
|
9
10
|
import { isFunction } from "@quiteer/is";
|
|
10
11
|
import { parserConfig } from "@quiteer/parser-config";
|
|
@@ -13,7 +14,7 @@ import { setTimeout } from "node:timers/promises";
|
|
|
13
14
|
import { getPortPromise } from "portfinder";
|
|
14
15
|
|
|
15
16
|
//#region package.json
|
|
16
|
-
var version = "0.1.
|
|
17
|
+
var version = "0.1.9";
|
|
17
18
|
|
|
18
19
|
//#endregion
|
|
19
20
|
//#region src/store.ts
|
|
@@ -25,13 +26,16 @@ store.set("mode", "development");
|
|
|
25
26
|
store.set("env", {});
|
|
26
27
|
store.set("minify", false);
|
|
27
28
|
store.set("port", 8080);
|
|
28
|
-
store.set("prefixes", ["QVITE_", "VITE_"]);
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/defaults.ts
|
|
32
|
-
function getDefaultOptions() {
|
|
32
|
+
function getDefaultOptions(config) {
|
|
33
33
|
const root$1 = store.get("root");
|
|
34
|
+
const minify = store.get("minify");
|
|
35
|
+
const localIconDir = config.localIconDir || "src/assets/icons";
|
|
34
36
|
return {
|
|
37
|
+
minify,
|
|
38
|
+
localIconDir,
|
|
35
39
|
UnoCSS: false,
|
|
36
40
|
plugins: {
|
|
37
41
|
Vue: [{ customElement: true }],
|
|
@@ -41,7 +45,12 @@ function getDefaultOptions() {
|
|
|
41
45
|
FileChangeLogger: false,
|
|
42
46
|
RemoveConsole: false,
|
|
43
47
|
MockRouter: false,
|
|
44
|
-
Icons:
|
|
48
|
+
Icons: [{
|
|
49
|
+
compiler: "vue3",
|
|
50
|
+
customCollections: { local: FileSystemIconLoader(resolve(root$1, localIconDir), (svg) => svg.replace(/^<svg\s/, "<svg width=\"1em\" height=\"1em\" ")) },
|
|
51
|
+
scale: 1,
|
|
52
|
+
defaultClass: "inline-block"
|
|
53
|
+
}],
|
|
45
54
|
SvgIcons: false,
|
|
46
55
|
AutoImport: [{ imports: [
|
|
47
56
|
"vue",
|
|
@@ -60,7 +69,7 @@ function getDefaultOptions() {
|
|
|
60
69
|
}],
|
|
61
70
|
resolvers: [NaiveUiResolver(), IconsResolver({
|
|
62
71
|
customCollections: "local",
|
|
63
|
-
componentPrefix: "icon-
|
|
72
|
+
componentPrefix: "icon-local"
|
|
64
73
|
})]
|
|
65
74
|
}]
|
|
66
75
|
},
|
|
@@ -72,11 +81,12 @@ function getDefaultOptions() {
|
|
|
72
81
|
vite: {
|
|
73
82
|
server: {
|
|
74
83
|
port: 3e3,
|
|
84
|
+
host: "0.0.0.0",
|
|
75
85
|
open: false,
|
|
76
86
|
strictPort: false
|
|
77
87
|
},
|
|
78
88
|
resolve: { alias: { "@": resolve(root$1, "src") } },
|
|
79
|
-
build: { minify
|
|
89
|
+
build: { minify }
|
|
80
90
|
}
|
|
81
91
|
};
|
|
82
92
|
}
|
|
@@ -125,7 +135,7 @@ function withUnoInjection(config) {
|
|
|
125
135
|
return next;
|
|
126
136
|
}
|
|
127
137
|
async function normalizeConfig(raw) {
|
|
128
|
-
return deepMerge(getDefaultOptions(), raw);
|
|
138
|
+
return deepMerge(getDefaultOptions(raw), raw);
|
|
129
139
|
}
|
|
130
140
|
function geVitePlugins(config) {
|
|
131
141
|
const { env, plugins } = config;
|
|
@@ -144,12 +154,18 @@ function geVitePlugins(config) {
|
|
|
144
154
|
}
|
|
145
155
|
async function toViteInlineConfig(config) {
|
|
146
156
|
const mode = store.get("mode");
|
|
157
|
+
const root$1 = store.get("root");
|
|
158
|
+
const plugins = geVitePlugins(config);
|
|
159
|
+
const userViteConfig = { ...config.vite };
|
|
160
|
+
const userPlugins = userViteConfig.plugins || [];
|
|
161
|
+
const userPluginsArray = Array.isArray(userPlugins) ? userPlugins : [userPlugins];
|
|
162
|
+
delete userViteConfig.plugins;
|
|
147
163
|
return mergeConfig({
|
|
148
164
|
configFile: false,
|
|
149
|
-
root:
|
|
165
|
+
root: root$1,
|
|
150
166
|
mode,
|
|
151
|
-
plugins:
|
|
152
|
-
},
|
|
167
|
+
plugins: [...userPluginsArray, ...plugins]
|
|
168
|
+
}, userViteConfig);
|
|
153
169
|
}
|
|
154
170
|
|
|
155
171
|
//#endregion
|
|
@@ -208,12 +224,13 @@ async function getConfig(filePath) {
|
|
|
208
224
|
const path$1 = await configPath(filePath);
|
|
209
225
|
const command = store.get("command");
|
|
210
226
|
const mode = store.get("mode");
|
|
227
|
+
const includePrefixes = ["QVITE_", "VITE_"];
|
|
211
228
|
await bootstrapEnv({
|
|
212
229
|
mode,
|
|
213
|
-
includePrefixes
|
|
230
|
+
includePrefixes
|
|
214
231
|
});
|
|
215
|
-
const modeEnv = loadEnv(mode, root,
|
|
216
|
-
const env = deepMerge({}, loadEnv("", root,
|
|
232
|
+
const modeEnv = loadEnv(mode, root, includePrefixes);
|
|
233
|
+
const env = deepMerge({}, loadEnv("", root, includePrefixes), modeEnv);
|
|
217
234
|
try {
|
|
218
235
|
const option = await parserConfig(path$1, "qvite.config");
|
|
219
236
|
if (isFunction(option)) return option({
|
|
@@ -258,7 +275,8 @@ async function getConfig(filePath) {
|
|
|
258
275
|
*/
|
|
259
276
|
async function watch(options) {
|
|
260
277
|
const normalized = await normalizeConfig(options);
|
|
261
|
-
const
|
|
278
|
+
const port = normalized.vite?.server?.port;
|
|
279
|
+
const p = await getPortPromise({ port });
|
|
262
280
|
store.set("port", p);
|
|
263
281
|
const inline = await toViteInlineConfig(normalized);
|
|
264
282
|
const viteDevServer = await createServer({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UserConfig, defineConfig as defineConfig$1 } from "tsdown";
|
|
2
2
|
import { UserConfig as UserConfig$1, defineConfig as defineConfig$2 } from "vite";
|
|
3
|
-
import { AutoImport, Components,
|
|
3
|
+
import { AutoImport, Components, FileSystemIconLoader, Icons, IconsResolver, NaiveUiResolver, Progress, Vue, VueDevTools, VueJsx, createSvgIconsPlugin } from "@quiteer/vite-plugins/plugins";
|
|
4
|
+
import { EnvConfig, EnvConfigPluginOptions, VirtualHtmlOptions, fileChangeLoggerPlugin, mockRouterPlugin, removeConsolePlugin } from "@quiteer/vite-plugins";
|
|
4
5
|
|
|
5
6
|
//#region src/typings.d.ts
|
|
6
7
|
type PluginOptions<T extends (...args: any) => any> = boolean | Parameters<T>;
|
|
@@ -18,6 +19,8 @@ interface QvitePlugins {
|
|
|
18
19
|
AutoImport?: PluginOptions<typeof AutoImport>;
|
|
19
20
|
}
|
|
20
21
|
interface QviteConfig {
|
|
22
|
+
minify?: boolean;
|
|
23
|
+
localIconDir?: string;
|
|
21
24
|
UnoCSS?: boolean;
|
|
22
25
|
vite?: UserConfig$1;
|
|
23
26
|
tsdown?: UserConfig | UserConfig[];
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig as defineConfig$1 } from "tsdown";
|
|
2
2
|
import { defineConfig as defineConfig$2 } from "vite";
|
|
3
|
-
import { FileSystemIconLoader, IconsResolver, NaiveUiResolver } from "@quiteer/vite-plugins";
|
|
3
|
+
import { FileSystemIconLoader, IconsResolver, NaiveUiResolver } from "@quiteer/vite-plugins/plugins";
|
|
4
4
|
|
|
5
5
|
//#region index.ts
|
|
6
6
|
function defineConfig(config) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiteer/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.9",
|
|
5
5
|
"description": "在 vite 的基础上增强的前端架构 cli",
|
|
6
6
|
"author": "quiteer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"vite": "npm:rolldown-vite@7.2.2",
|
|
61
61
|
"zx": "^8.8.5",
|
|
62
62
|
"@quiteer/is": "0.0.2",
|
|
63
|
-
"@quiteer/
|
|
64
|
-
"@quiteer/
|
|
65
|
-
"@quiteer/vite-plugins": "^0.1.
|
|
63
|
+
"@quiteer/unocss": "0.0.6",
|
|
64
|
+
"@quiteer/utils": "0.0.4",
|
|
65
|
+
"@quiteer/vite-plugins": "^0.1.4"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"dev": "tsdown -w",
|
package/uno.config.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import type { VitePluginConfig } from '@unocss/vite'
|
|
2
|
+
import { defineConfig, NaiveUIPreset, QuiteerPreset } from '@quiteer/unocss'
|
|
3
|
+
|
|
4
|
+
export default (userConfig: VitePluginConfig) => {
|
|
5
|
+
return defineConfig({
|
|
6
|
+
content: {
|
|
7
|
+
pipeline: {
|
|
8
|
+
exclude: ['node_modules', 'dist']
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
presets: [
|
|
12
|
+
QuiteerPreset(),
|
|
13
|
+
NaiveUIPreset()
|
|
14
|
+
],
|
|
15
|
+
...userConfig
|
|
16
|
+
})
|
|
17
|
+
}
|