@dlzn-ui/vite-config 1.67.0 → 1.68.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.
Files changed (2) hide show
  1. package/dist/index.mjs +44 -3
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import path, { basename, resolve, posix } from 'node:path';
1
+ import path, { basename, resolve, relative, posix } from 'node:path';
2
2
  import AutoImport from 'unplugin-auto-import/vite';
3
3
  import ElementPlus from 'unplugin-element-plus/vite';
4
4
  import Components from 'unplugin-vue-components/vite';
@@ -15,6 +15,7 @@ import browserslist from 'browserslist';
15
15
  import { browserslistToTargets } from 'lightningcss';
16
16
  import tailwindAutoReference from 'vite-plugin-vue-tailwind-auto-reference';
17
17
  import { TDesignResolver } from '@tdesign-vue-next/auto-import-resolver';
18
+ import { existsSync } from 'node:fs';
18
19
  import { webUpdateNotice } from '@plugin-web-update-notification/vite';
19
20
  import { visualizer } from 'rollup-plugin-visualizer';
20
21
  import { compression } from 'vite-plugin-compression2';
@@ -152,6 +153,43 @@ const tDesignAutoImportResolve = (options) => {
152
153
  ];
153
154
  };
154
155
 
156
+ const VIRTUAL_ID = "virtual:dlzn-ui/app-params";
157
+ const RESOLVED_ID = `\0${VIRTUAL_ID}`;
158
+ const virtualAppParams = (options) => {
159
+ const userFile = resolve(options.root, options.appParamsFile ?? "app-params.ts");
160
+ const viewsGlob = options.viewsGlob ?? "@/views/**/index.vue";
161
+ return {
162
+ buildStart() {
163
+ if (!existsSync(userFile)) {
164
+ throw new Error(
165
+ `[dlzn-ui] \u672A\u627E\u5230 ${userFile}\uFF0C\u8BF7\u5BFC\u51FA busFormItems / busComponentInitialValueMap / useListPromiseMap`
166
+ );
167
+ }
168
+ },
169
+ enforce: "pre",
170
+ load(id) {
171
+ if (id !== RESOLVED_ID) {
172
+ return;
173
+ }
174
+ const userId = `/${relative(options.root, userFile).replace(/\\/g, "/")}`;
175
+ return `
176
+ import user from ${JSON.stringify(userId)}
177
+
178
+ export default {
179
+ ...user,
180
+ viewsEntryLazyImport: import.meta.glob(${JSON.stringify(viewsGlob)}),
181
+ }
182
+ `;
183
+ },
184
+ name: "dlzn-ui:app-params",
185
+ resolveId(id) {
186
+ if (id === VIRTUAL_ID) {
187
+ return RESOLVED_ID;
188
+ }
189
+ }
190
+ };
191
+ };
192
+
155
193
  const ENDPOINT = "/__dev__/save-folder-alias";
156
194
  const OUTPUT_FILE_WATCH_IGNORE = "**/folder-alias.json";
157
195
  const SKIP_COMPONENTS = /* @__PURE__ */ new Set(["Layout", "ParentView"]);
@@ -410,6 +448,7 @@ const index = (_env, options) => {
410
448
  },
411
449
  // envDir, // 将 env 文件里面的变量注入到 import.meta.env 里面
412
450
  optimizeDeps: {
451
+ exclude: ["dlzn-ui"],
413
452
  include: [
414
453
  "tdesign-vue-next/dist/tdesign.min.js",
415
454
  "path-browserify",
@@ -444,14 +483,16 @@ const index = (_env, options) => {
444
483
  "element-plus/es/locale/lang/zh-cn",
445
484
  "element-plus/es/components/date-picker/style/css",
446
485
  "element-plus/es/components/scrollbar/style/css",
447
- "color",
448
- "dlzn-ui"
486
+ "color"
449
487
  ]
450
488
  },
451
489
  plugins: [
452
490
  // envParse({
453
491
  // dtsPath: 'types/env.d.ts',
454
492
  // }),
493
+ virtualAppParams({
494
+ root: options.root
495
+ }),
455
496
  createHtmlPlugin({
456
497
  entry: `/src/main.${isProduction ? "prod" : "dev"}.ts`,
457
498
  // 必须绝对路径,否则类似system/log/operlog 二级页面打不开
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dlzn-ui/vite-config",
3
3
  "type": "module",
4
- "version": "1.67.0",
4
+ "version": "1.68.0",
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": "1.67.0"
40
+ "@dlzn-ui/node-utils": "1.68.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "rimraf": "^6.1.3",