@dlzn-ui/vite-config 2.0.16 → 2.0.22
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +36 -22
- package/package.json +2 -3
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ type Arrayable<T> = Array<T> | T;
|
|
|
6
6
|
interface Options {
|
|
7
7
|
autoImportResolvers?: Array<UnwrapArrayable<UnwrapArrayable<NonNullable<Parameters<typeof AutoImport>[0]['resolvers']>>>>;
|
|
8
8
|
autoImports?: AutoImports;
|
|
9
|
+
isPlay?: boolean;
|
|
9
10
|
root: string;
|
|
10
11
|
}
|
|
11
12
|
type UnwrapArrayable<T> = T extends Arrayable<infer U> ? U : never;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type Arrayable<T> = Array<T> | T;
|
|
|
6
6
|
interface Options {
|
|
7
7
|
autoImportResolvers?: Array<UnwrapArrayable<UnwrapArrayable<NonNullable<Parameters<typeof AutoImport>[0]['resolvers']>>>>;
|
|
8
8
|
autoImports?: AutoImports;
|
|
9
|
+
isPlay?: boolean;
|
|
9
10
|
root: string;
|
|
10
11
|
}
|
|
11
12
|
type UnwrapArrayable<T> = T extends Arrayable<infer U> ? U : never;
|
package/dist/index.mjs
CHANGED
|
@@ -140,13 +140,18 @@ const tDesignAutoImportResolve = (options) => {
|
|
|
140
140
|
|
|
141
141
|
const VIRTUAL_ID = "virtual:dlzn-ui/app-params";
|
|
142
142
|
const RESOLVED_ID = `\0${VIRTUAL_ID}`;
|
|
143
|
-
const virtualAppParams = () => {
|
|
143
|
+
const virtualAppParams = ({ isPlay }) => {
|
|
144
144
|
return {
|
|
145
145
|
enforce: "pre",
|
|
146
146
|
load(id) {
|
|
147
147
|
if (id !== RESOLVED_ID) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
+
if (isPlay) {
|
|
151
|
+
return `
|
|
152
|
+
export default {}
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
150
155
|
return `
|
|
151
156
|
import user from "@/app-params.ts"
|
|
152
157
|
import layoutsEntryLazyImport from "@/layout/index.ts"
|
|
@@ -198,8 +203,11 @@ const virtualAppParams = () => {
|
|
|
198
203
|
const ENDPOINT = "/__dev__/save-folder-alias";
|
|
199
204
|
const OUTPUT_FILE_WATCH_IGNORE = "**/folder-alias.json";
|
|
200
205
|
const SKIP_COMPONENTS = /* @__PURE__ */ new Set(["Layout", "ParentView"]);
|
|
201
|
-
function devSaveFolderAlias(
|
|
202
|
-
|
|
206
|
+
function devSaveFolderAlias({
|
|
207
|
+
isPlay,
|
|
208
|
+
root
|
|
209
|
+
}) {
|
|
210
|
+
const OUTPUT_FILE = resolve(root, isPlay ? "play/folder-alias.json" : "folder-alias.json");
|
|
203
211
|
return {
|
|
204
212
|
apply: "serve",
|
|
205
213
|
// Vite 对插件 config() 的返回值会做深度合并(mergeConfig)
|
|
@@ -298,7 +306,7 @@ function toFolderAlias(routers) {
|
|
|
298
306
|
}
|
|
299
307
|
|
|
300
308
|
const vitePlugins = (options) => {
|
|
301
|
-
const { isProduction, root } = options;
|
|
309
|
+
const { isPlay, isProduction, root } = options;
|
|
302
310
|
if (isProduction) {
|
|
303
311
|
return [
|
|
304
312
|
viteImagemin({
|
|
@@ -375,7 +383,10 @@ const vitePlugins = (options) => {
|
|
|
375
383
|
},
|
|
376
384
|
name: "filter-vite-server-urls"
|
|
377
385
|
},
|
|
378
|
-
devSaveFolderAlias(
|
|
386
|
+
devSaveFolderAlias({
|
|
387
|
+
isPlay,
|
|
388
|
+
root
|
|
389
|
+
})
|
|
379
390
|
];
|
|
380
391
|
}
|
|
381
392
|
};
|
|
@@ -392,8 +403,9 @@ function needPort(target) {
|
|
|
392
403
|
}
|
|
393
404
|
const index = (_env, options) => {
|
|
394
405
|
const { command, mode } = _env;
|
|
395
|
-
const
|
|
396
|
-
const
|
|
406
|
+
const { isPlay = false, root } = options;
|
|
407
|
+
const resolvePath = (p) => resolve(root, p);
|
|
408
|
+
const envDir = isPlay ? "play/env" : "env";
|
|
397
409
|
const env = parseLoadedEnv(loadEnv(mode, envDir));
|
|
398
410
|
const {
|
|
399
411
|
VITE_API_PROXY_PORT_ARRAY,
|
|
@@ -423,7 +435,7 @@ const index = (_env, options) => {
|
|
|
423
435
|
};
|
|
424
436
|
return mergeConfig(
|
|
425
437
|
baseConfigFn({
|
|
426
|
-
tailwindAutoReferenceEntry: "node_modules/dlzn-ui/assets/css/tailwindcss-entry.css"
|
|
438
|
+
tailwindAutoReferenceEntry: isPlay ? "assets/css/tailwindcss-entry.css" : "node_modules/dlzn-ui/assets/css/tailwindcss-entry.css"
|
|
427
439
|
}),
|
|
428
440
|
{
|
|
429
441
|
build: {
|
|
@@ -459,9 +471,11 @@ const index = (_env, options) => {
|
|
|
459
471
|
// envParse({
|
|
460
472
|
// dtsPath: 'types/env.d.ts',
|
|
461
473
|
// }),
|
|
462
|
-
virtualAppParams(
|
|
474
|
+
virtualAppParams({
|
|
475
|
+
isPlay
|
|
476
|
+
}),
|
|
463
477
|
createHtmlPlugin({
|
|
464
|
-
entry: "/src/main.ts",
|
|
478
|
+
entry: isPlay ? "/play/main.play.ts" : "/src/main.ts",
|
|
465
479
|
// 必须绝对路径,否则类似system/log/operlog 二级页面打不开
|
|
466
480
|
inject: {
|
|
467
481
|
data: {
|
|
@@ -469,12 +483,12 @@ const index = (_env, options) => {
|
|
|
469
483
|
title: VITE_APP_NAME
|
|
470
484
|
},
|
|
471
485
|
ejsOptions: {
|
|
472
|
-
views: ["node_modules/dlzn-ui/assets/ejs"]
|
|
486
|
+
views: [isPlay ? "assets/ejs" : "node_modules/dlzn-ui/assets/ejs"]
|
|
473
487
|
}
|
|
474
488
|
},
|
|
475
489
|
minify: true,
|
|
476
490
|
// 相对消费方 root,closeBundle 整理 HTML 时比绝对路径更稳
|
|
477
|
-
template: "node_modules/dlzn-ui/index.html"
|
|
491
|
+
template: isPlay ? "index.html" : "node_modules/dlzn-ui/index.html"
|
|
478
492
|
}),
|
|
479
493
|
{
|
|
480
494
|
apply: "build",
|
|
@@ -504,7 +518,7 @@ const index = (_env, options) => {
|
|
|
504
518
|
name: "dlzn-ui:flatten-index-html"
|
|
505
519
|
},
|
|
506
520
|
VueRouter({
|
|
507
|
-
dts: "types/typed-router.d.ts
|
|
521
|
+
dts: `${isPlay ? "play/" : ""}types/typed-router.d.ts`
|
|
508
522
|
}),
|
|
509
523
|
AutoImport({
|
|
510
524
|
// 用于自动导入 函数/工具库 的 API
|
|
@@ -520,7 +534,7 @@ const index = (_env, options) => {
|
|
|
520
534
|
types: false
|
|
521
535
|
// Enable auto import the types under the directories
|
|
522
536
|
},
|
|
523
|
-
dts: "types/auto-imports.d.ts
|
|
537
|
+
dts: `${isPlay ? "play/" : ""}types/auto-imports.d.ts`,
|
|
524
538
|
// dtsMode: 'overwrite', // overwrite the whole existing .d.ts file with the new type definitions.
|
|
525
539
|
imports: [
|
|
526
540
|
"vue",
|
|
@@ -547,13 +561,13 @@ const index = (_env, options) => {
|
|
|
547
561
|
imports: ["PageListProps"],
|
|
548
562
|
type: true
|
|
549
563
|
},
|
|
550
|
-
autoImportStoreList(
|
|
564
|
+
autoImportStoreList(root),
|
|
551
565
|
...options.autoImports ?? []
|
|
552
566
|
],
|
|
553
567
|
resolvers: [
|
|
554
568
|
...options.autoImportResolvers ?? [],
|
|
555
569
|
...tDesignAutoImportResolve({
|
|
556
|
-
root
|
|
570
|
+
root
|
|
557
571
|
})
|
|
558
572
|
],
|
|
559
573
|
vueTemplate: true
|
|
@@ -562,28 +576,28 @@ const index = (_env, options) => {
|
|
|
562
576
|
Components({
|
|
563
577
|
deep: false,
|
|
564
578
|
// 用于自动导入 Vue 组件
|
|
565
|
-
dts: "types/components.d.ts
|
|
579
|
+
dts: `${isPlay ? "play/" : ""}types/components.d.ts`,
|
|
566
580
|
resolvers: [
|
|
567
581
|
...options.autoImportResolvers ?? [],
|
|
568
582
|
...tDesignAutoImportResolve({
|
|
569
|
-
root
|
|
583
|
+
root
|
|
570
584
|
})
|
|
571
585
|
]
|
|
572
586
|
// syncMode: 'overwrite',
|
|
573
587
|
}),
|
|
574
|
-
...vitePlugins({ isProduction, root
|
|
588
|
+
...vitePlugins({ isPlay, isProduction, root })
|
|
575
589
|
],
|
|
576
590
|
resolve: {
|
|
577
591
|
alias: [
|
|
578
592
|
{
|
|
579
593
|
find: "@",
|
|
580
|
-
replacement: resolvePath("src")
|
|
594
|
+
replacement: resolvePath(isPlay ? "" : "src")
|
|
581
595
|
// 使用绝对路径(官方推荐)
|
|
582
596
|
},
|
|
583
597
|
{
|
|
584
598
|
find: "img",
|
|
585
599
|
// 路径以 img 开头
|
|
586
|
-
replacement: resolvePath("src/assets/images")
|
|
600
|
+
replacement: resolvePath(isPlay ? "assets/images" : "src/assets/images")
|
|
587
601
|
}
|
|
588
602
|
// ...(isProduction
|
|
589
603
|
// ? []
|
|
@@ -601,7 +615,7 @@ const index = (_env, options) => {
|
|
|
601
615
|
extensions: [".ts", ".mjs", ".js"]
|
|
602
616
|
// js 和 mjs 打包chat包时需要
|
|
603
617
|
},
|
|
604
|
-
root
|
|
618
|
+
root,
|
|
605
619
|
server: {
|
|
606
620
|
// vite preview 也会走该代理
|
|
607
621
|
host: "0.0.0.0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dlzn-ui/vite-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.22",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"vite-plugin-imagemin": "^0.6.1",
|
|
38
38
|
"vite-plugin-vue-tailwind-auto-reference": "^2.0.2",
|
|
39
39
|
"vue-router": "^5.2.0",
|
|
40
|
-
"@dlzn-ui/node-utils": "2.0.
|
|
40
|
+
"@dlzn-ui/node-utils": "2.0.22"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"rimraf": "^6.1.3",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "unbuild",
|
|
48
|
-
"clean": "rimraf dist",
|
|
49
48
|
"stub": "unbuild --stub"
|
|
50
49
|
}
|
|
51
50
|
}
|