@nikoyo-spa/vite-config 0.0.0-patch.0 → 1.0.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/build.config.ts CHANGED
@@ -4,4 +4,21 @@ export default defineBuildConfig({
4
4
  clean: true,
5
5
  declaration: true,
6
6
  entries: ['src/index'],
7
+ externals: [
8
+ '@tailwindcss/vite',
9
+ '@unhead/vue',
10
+ '@vitejs/plugin-vue',
11
+ 'unplugin-auto-import/vite',
12
+ 'unplugin-icons',
13
+ 'unplugin-vue-components',
14
+ 'unplugin-vue-router',
15
+ 'vite',
16
+ 'unplugin-auto-import/vite',
17
+ 'vite-plugin-compression2',
18
+ 'vite-plugin-vue-devtools',
19
+ 'vite-plugin-vue-layouts',
20
+ 'vite-plugin-webfont-dl',
21
+ 'vite-plugin-single-spa',
22
+ /@nikoyo-spa\/.*/
23
+ ],
7
24
  })
package/dist/index.d.mts CHANGED
@@ -1,2 +1,5 @@
1
- export * from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
2
- export { default } from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
1
+ import * as vite from 'vite';
2
+
3
+ declare function defineConfig(userConfig?: Record<string, any>): vite.UserConfigFnObject;
4
+
5
+ export { defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- export * from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
2
- export { default } from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
1
+ import * as vite from 'vite';
2
+
3
+ declare function defineConfig(userConfig?: Record<string, any>): vite.UserConfigFnObject;
4
+
5
+ export { defineConfig };
package/dist/index.mjs CHANGED
@@ -1,19 +1,207 @@
1
- import { createJiti } from "../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs";
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { VITE_BUILD_EXTERNAL } from '@nikoyo-spa/import-map-shared';
4
+ import { NikoyoSPACoreResolver, NikoyoSPAComponentsResolver } from '@nikoyo-spa/resolvers';
5
+ import Tailwindcss from '@tailwindcss/vite';
6
+ import { unheadVueComposablesImports } from '@unhead/vue';
7
+ import Vue from '@vitejs/plugin-vue';
8
+ import AutoImport from 'unplugin-auto-import/vite';
9
+ import { FileSystemIconLoader } from 'unplugin-icons/loaders';
10
+ import IconsResolver from 'unplugin-icons/resolver';
11
+ import Icons from 'unplugin-icons/vite';
12
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
13
+ import Components from 'unplugin-vue-components/vite';
14
+ import { VueRouterAutoImports } from 'unplugin-vue-router';
15
+ import VueRouter from 'unplugin-vue-router/vite';
16
+ import { defineConfig as defineConfig$1, loadEnv, mergeConfig } from 'vite';
17
+ import { compression } from 'vite-plugin-compression2';
18
+ import VitePluginSingleSpa from 'vite-plugin-single-spa';
19
+ import VueDevTools from 'vite-plugin-vue-devtools';
20
+ import Layouts from 'vite-plugin-vue-layouts';
21
+ import WebfontDownload from 'vite-plugin-webfont-dl';
2
22
 
3
- const jiti = createJiti(import.meta.url, {
4
- "interopDefault": true,
5
- "alias": {
6
- "@nikoyo-spa/vite-config": "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config"
7
- },
8
- "transformOptions": {
9
- "babel": {
10
- "plugins": []
23
+ function defineConfig(userConfig = {}) {
24
+ return defineConfig$1(({ command, mode }) => {
25
+ const env = loadEnv(mode, process.cwd());
26
+ const {
27
+ VITE_BASE_URL = "/",
28
+ // 打包路径
29
+ VITE_API_URL = "/",
30
+ // 接口路径
31
+ VITE_DEV_PORT = 8081,
32
+ VITE_PROXY_HOST = "http://localhost:8080"
33
+ } = env;
34
+ const port = +VITE_DEV_PORT;
35
+ const isBuild = command === "build";
36
+ const pkgPath = path.resolve(process.cwd(), "package.json");
37
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
38
+ const { name } = pkg;
39
+ const isRoot = name.startsWith("@nikoyo-spa/root-");
40
+ let singleSpaConfig;
41
+ let base;
42
+ if (isRoot) {
43
+ base = VITE_BASE_URL;
44
+ singleSpaConfig = {
45
+ type: "root",
46
+ imo: () => "/shared/import-map-overrides@3.1.1.js",
47
+ importMaps: {
48
+ dev: ["src/importMap.dev.json", "node_modules/@nikoyo-spa/import-map-shared/dist/shared/importMap.shared.json"],
49
+ build: ["src/importMap.json", "node_modules/@nikoyo-spa/import-map-shared/dist/shared/importMap.shared.json"]
50
+ }
51
+ };
52
+ } else {
53
+ const projectId = name.replace("@nikoyo-spa/app-", "");
54
+ base = `/modules/${projectId}/`;
55
+ singleSpaConfig = {
56
+ type: "mife",
57
+ serverPort: port,
58
+ spaEntryPoints: "src/main.ts",
59
+ projectId
60
+ };
11
61
  }
12
- }
13
- })
62
+ return mergeConfig(
63
+ {
64
+ base,
65
+ define: {
66
+ __BASE_URL__: JSON.stringify(VITE_BASE_URL),
67
+ __API_URL__: JSON.stringify(VITE_API_URL)
68
+ },
69
+ resolve: {
70
+ alias: {
71
+ "@": path.resolve(process.cwd(), "./src")
72
+ }
73
+ },
74
+ plugins: [
75
+ // https://github.com/vitejs/vite-plugin-vue
76
+ Vue(),
77
+ // https://github.com/posva/unplugin-vue-router
78
+ VueRouter({
79
+ extensions: [".vue"],
80
+ routesFolder: [
81
+ "./src/pages"
82
+ ],
83
+ dts: "src/typed-router.d.ts"
84
+ }),
85
+ // https://github.com/johncampionjr/vite-plugin-vue-layouts
86
+ Layouts(),
87
+ // https://github.com/tailwindlabs/tailwindcss
88
+ Tailwindcss(),
89
+ // https://github.com/unplugin/unplugin-auto-import
90
+ AutoImport({
91
+ imports: [
92
+ "vue",
93
+ "vue-i18n",
94
+ "@vueuse/core",
95
+ "pinia",
96
+ unheadVueComposablesImports,
97
+ VueRouterAutoImports,
98
+ NikoyoSPACoreResolver(),
99
+ {
100
+ "vue-router/auto": ["useLink"],
101
+ "element-plus": ["ElMessage", "ElLoading"]
102
+ }
103
+ ],
104
+ resolvers: [
105
+ ElementPlusResolver({ importStyle: false }),
106
+ IconsResolver({
107
+ prefix: "Icon"
108
+ })
109
+ ],
110
+ dirs: ["src/apis/**", "src/constants/**", "src/composables/**", "src/stores/**", "src/utils/**"],
111
+ dts: "src/auto-imports.d.ts",
112
+ vueTemplate: true
113
+ }),
114
+ // https://github.com/unplugin/unplugin-vue-components
115
+ Components({
116
+ resolvers: [
117
+ ElementPlusResolver({ importStyle: false }),
118
+ NikoyoSPAComponentsResolver(),
119
+ IconsResolver({
120
+ enabledCollections: ["ep", "mdi", "carbon"],
121
+ customCollections: ["custom", "nikoyo"]
122
+ })
123
+ ],
124
+ extensions: ["vue"],
125
+ include: [/\.vue$/, /\.vue\?vue/],
126
+ dts: "src/components.d.ts"
127
+ }),
128
+ // https://github.com/unplugin/unplugin-icons
129
+ Icons({
130
+ autoInstall: true,
131
+ customCollections: {
132
+ custom: FileSystemIconLoader(
133
+ path.resolve(process.cwd(), "./src/assets/icons"),
134
+ (svg) => svg.replace(/^<svg /, '<svg fill="currentColor" ')
135
+ ),
136
+ nikoyo: async (iconName) => {
137
+ const icons = await import('@nikoyo-spa/icons');
138
+ const icon = icons.default?.[kebabToPascalCase(iconName)];
139
+ if (!icon) {
140
+ throw new Error(`[nikoyo-icons] Icon "${iconName}" not found`);
141
+ }
142
+ return renderAntdAstToSvg(icon.icon);
143
+ }
144
+ }
145
+ }),
146
+ // https://github.com/feat-agency/vite-plugin-webfont-dl
147
+ WebfontDownload(),
148
+ // https://github.com/nonzzz/vite-plugin-compression
149
+ compression(),
150
+ // https://github.com/vuejs/devtools
151
+ VueDevTools(),
152
+ // https://github.com/WJSoftware/vite-plugin-single-spa
153
+ VitePluginSingleSpa(singleSpaConfig)
154
+ ],
155
+ build: {
156
+ rollupOptions: {
157
+ external: VITE_BUILD_EXTERNAL
158
+ },
159
+ cssCodeSplit: true,
160
+ esbuild: isBuild ? { drop: ["console", "debugger"] } : {}
161
+ },
162
+ server: {
163
+ hmr: true,
164
+ host: true,
165
+ port,
166
+ proxy: {
167
+ "/svc": VITE_PROXY_HOST,
168
+ "/token": VITE_PROXY_HOST,
169
+ "/login": VITE_PROXY_HOST,
170
+ "/pub": VITE_PROXY_HOST
171
+ }
172
+ }
173
+ },
174
+ userConfig
175
+ );
176
+ });
177
+ }
178
+ function kebabToPascalCase(str) {
179
+ return str.split("-").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("");
180
+ }
181
+ function renderAntdAstToSvg(icon) {
182
+ const { tag, attrs = {}, children = [] } = icon;
183
+ return `
184
+ <svg
185
+ ${renderAttrs({
186
+ ...attrs,
187
+ fill: "currentColor",
188
+ xmlns: "http://www.w3.org/2000/svg"
189
+ })}
190
+ >
191
+ ${children.map(renderNode).join("")}
192
+ </svg>
193
+ `;
194
+ }
195
+ function renderNode(node) {
196
+ const { tag, attrs = {}, children = [] } = node;
197
+ return `
198
+ <${tag} ${renderAttrs(attrs)}>
199
+ ${children.map(renderNode).join("")}
200
+ </${tag}>
201
+ `;
202
+ }
203
+ function renderAttrs(attrs) {
204
+ return Object.entries(attrs).map(([k, v]) => `${k}="${v}"`).join(" ");
205
+ }
14
206
 
15
- /** @type {import("D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js")} */
16
- const _module = await jiti.import("D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.ts");
17
-
18
- export default _module?.default ?? _module;
19
- export const viteConfig = _module.viteConfig;
207
+ export { defineConfig };
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "@nikoyo-spa/vite-config",
3
3
  "type": "module",
4
- "version": "0.0.0-patch.0",
4
+ "version": "1.0.0",
5
+ "description": "Spa Vite Config",
6
+ "author": "qianyongdong <https://github.com/qianyongdong>",
5
7
  "license": "MIT",
8
+ "homepage": "https://github.com/nikoyo-spa/nikoyo-spa-client/tree/main/packages/vite-config#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nikoyo-spa/nikoyo-spa-client.git",
12
+ "directory": "packages/vite-config"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/nikoyo-spa/nikoyo-spa-client/issues"
16
+ },
6
17
  "exports": {
7
18
  ".": {
8
19
  "types": "./src/index.ts",
@@ -15,50 +26,41 @@
15
26
  "files": [
16
27
  "*"
17
28
  ],
18
- "peerDependencies": {
19
- "@tailwindcss/vite": "^4.1.14",
20
- "@unhead/vue": "^2.0.19",
21
- "@vitejs/plugin-vue": "^6.0.1",
22
- "unplugin-auto-import": "^20.2.0",
23
- "unplugin-icons": "^22.4.2",
24
- "unplugin-vue-components": "^29.1.0",
25
- "unplugin-vue-router": "^0.15.0",
26
- "vite-plugin-compression2": "^2.2.1",
27
- "vite-plugin-inspect": "^11.1.0",
28
- "vite-plugin-vue-layouts": "^0.11.0",
29
- "vite-plugin-webfont-dl": "^3.11.1",
30
- "@nikoyo-spa/components": "0.0.0",
31
- "@nikoyo-spa/core": "0.0.0",
32
- "@nikoyo-spa/resolvers": "0.0.0",
33
- "@nikoyo-spa/metadata": "0.0.0"
34
- },
35
29
  "dependencies": {
36
- "resolve.exports": "^2.0.3"
37
- },
38
- "devDependencies": {
39
- "@tailwindcss/vite": "^4.1.14",
40
- "@tsconfig/node22": "^22.0.2",
41
- "@types/node": "^24.7.1",
30
+ "@iconify-json/carbon": "^1.2.15",
31
+ "@iconify-json/ep": "^1.2.2",
32
+ "@iconify-json/mdi": "^1.2.3",
33
+ "@tailwindcss/vite": "^4.1.18",
34
+ "@tsconfig/node22": "^22.0.5",
35
+ "@types/node": "^25.0.3",
42
36
  "@unhead/vue": "^2.0.19",
43
- "@vitejs/plugin-vue": "^6.0.1",
44
- "tsx": "^4.19.4",
37
+ "@vitejs/plugin-vue": "^6.0.3",
38
+ "@vueuse/core": "^14.1.0",
39
+ "element-plus": "^2.12.0",
40
+ "pinia": "^3.0.4",
45
41
  "typescript": "^5.9.3",
46
- "unbuild": "^3.5.0",
47
- "unplugin-auto-import": "^20.2.0",
48
- "unplugin-icons": "^22.4.2",
49
- "unplugin-vue-components": "^29.1.0",
50
- "unplugin-vue-router": "^0.15.0",
51
- "vite": "^7.1.9",
52
- "vite-plugin-compression2": "^2.2.1",
42
+ "unplugin-auto-import": "^20.3.0",
43
+ "unplugin-icons": "^22.5.0",
44
+ "unplugin-vue-components": "^30.0.0",
45
+ "unplugin-vue-router": "^0.19.1",
46
+ "vite": "^7.3.0",
47
+ "vite-plugin-compression2": "^2.4.0",
53
48
  "vite-plugin-inspect": "^11.1.0",
49
+ "vite-plugin-single-spa": "^1.1.0",
54
50
  "vite-plugin-vue-layouts": "^0.11.0",
55
51
  "vite-plugin-webfont-dl": "^3.11.1",
56
- "@nikoyo-spa/components": "0.0.0",
57
- "@nikoyo-spa/resolvers": "0.0.0",
58
- "@nikoyo-spa/core": "0.0.0",
59
- "@nikoyo-spa/metadata": "0.0.0"
52
+ "vue": "^3.5.25",
53
+ "vue-i18n": "^11.2.2",
54
+ "vue-router": "^4.6.4",
55
+ "@nikoyo-spa/components": "1.0.0",
56
+ "@nikoyo-spa/core": "1.0.0",
57
+ "@nikoyo-spa/icons": "1.0.0",
58
+ "@nikoyo-spa/import-map-shared": "1.0.0",
59
+ "@nikoyo-spa/metadata": "1.0.0",
60
+ "@nikoyo-spa/resolvers": "1.0.0"
60
61
  },
61
62
  "scripts": {
63
+ "build": "pnpm unbuild",
62
64
  "stub": "pnpm unbuild --stub"
63
65
  }
64
66
  }
package/src/index.ts CHANGED
@@ -1 +1,227 @@
1
- export * from './vite.config'
1
+ import type { SingleSpaPluginOptions } from 'vite-plugin-single-spa'
2
+ import fs from 'node:fs'
3
+
4
+ import path from 'node:path'
5
+ import { VITE_BUILD_EXTERNAL } from '@nikoyo-spa/import-map-shared'
6
+ import { NikoyoSPAComponentsResolver, NikoyoSPACoreResolver } from '@nikoyo-spa/resolvers'
7
+ import Tailwindcss from '@tailwindcss/vite'
8
+ import { unheadVueComposablesImports } from '@unhead/vue'
9
+ import Vue from '@vitejs/plugin-vue'
10
+ import AutoImport from 'unplugin-auto-import/vite'
11
+ import { FileSystemIconLoader } from 'unplugin-icons/loaders'
12
+ import IconsResolver from 'unplugin-icons/resolver'
13
+ import Icons from 'unplugin-icons/vite'
14
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
15
+ import Components from 'unplugin-vue-components/vite'
16
+ import { VueRouterAutoImports } from 'unplugin-vue-router'
17
+ import VueRouter from 'unplugin-vue-router/vite'
18
+ import { loadEnv, mergeConfig, defineConfig as viteDefineConfig } from 'vite'
19
+ import { compression } from 'vite-plugin-compression2'
20
+ import VitePluginSingleSpa from 'vite-plugin-single-spa'
21
+ import VueDevTools from 'vite-plugin-vue-devtools'
22
+ import Layouts from 'vite-plugin-vue-layouts'
23
+ import WebfontDownload from 'vite-plugin-webfont-dl'
24
+
25
+ function defineConfig(userConfig: Record<string, any> = {}) {
26
+ return viteDefineConfig(({ command, mode }) => {
27
+ // 加载环境变量
28
+ const env = loadEnv(mode, process.cwd())
29
+ const {
30
+ VITE_BASE_URL = '/', // 打包路径
31
+ VITE_API_URL = '/', // 接口路径
32
+ VITE_DEV_PORT = 8081,
33
+ VITE_PROXY_HOST = 'http://localhost:8080',
34
+ } = env
35
+ const port = +VITE_DEV_PORT
36
+ const isBuild = command === 'build'
37
+
38
+ // 获取spa配置
39
+ const pkgPath = path.resolve(process.cwd(), 'package.json')
40
+ const pkg: { name: string } = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
41
+ const { name } = pkg
42
+ const isRoot = name.startsWith('@nikoyo-spa/root-')
43
+ let singleSpaConfig: SingleSpaPluginOptions
44
+ let base: string
45
+
46
+ if (isRoot) {
47
+ base = VITE_BASE_URL
48
+ singleSpaConfig = {
49
+ type: 'root',
50
+ imo: () => '/shared/import-map-overrides@3.1.1.js',
51
+ importMaps: {
52
+ dev: ['src/importMap.dev.json', 'node_modules/@nikoyo-spa/import-map-shared/dist/shared/importMap.shared.json'],
53
+ build: ['src/importMap.json', 'node_modules/@nikoyo-spa/import-map-shared/dist/shared/importMap.shared.json'],
54
+ },
55
+ }
56
+ }
57
+ else {
58
+ const projectId = name.replace('@nikoyo-spa/app-', '')
59
+ base = `/modules/${projectId}/`
60
+ singleSpaConfig = {
61
+ type: 'mife',
62
+ serverPort: port,
63
+ spaEntryPoints: 'src/main.ts',
64
+ projectId,
65
+ }
66
+ }
67
+
68
+ return mergeConfig(
69
+ {
70
+ base,
71
+ define: {
72
+ __BASE_URL__: JSON.stringify(VITE_BASE_URL),
73
+ __API_URL__: JSON.stringify(VITE_API_URL),
74
+ },
75
+ resolve: {
76
+ alias: {
77
+ '@': path.resolve(process.cwd(), './src'),
78
+ },
79
+ },
80
+ plugins: [
81
+ // https://github.com/vitejs/vite-plugin-vue
82
+ Vue(),
83
+ // https://github.com/posva/unplugin-vue-router
84
+ VueRouter({
85
+ extensions: ['.vue'],
86
+ routesFolder: [
87
+ './src/pages',
88
+ ],
89
+ dts: 'src/typed-router.d.ts',
90
+ }),
91
+ // https://github.com/johncampionjr/vite-plugin-vue-layouts
92
+ Layouts(),
93
+ // https://github.com/tailwindlabs/tailwindcss
94
+ Tailwindcss(),
95
+ // https://github.com/unplugin/unplugin-auto-import
96
+ AutoImport({
97
+ imports: [
98
+ 'vue',
99
+ 'vue-i18n',
100
+ '@vueuse/core',
101
+ 'pinia',
102
+ unheadVueComposablesImports,
103
+ VueRouterAutoImports,
104
+ NikoyoSPACoreResolver(),
105
+ {
106
+ 'vue-router/auto': ['useLink'],
107
+ 'element-plus': ['ElMessage', 'ElLoading'],
108
+ },
109
+ ],
110
+ resolvers: [
111
+ ElementPlusResolver({ importStyle: false }),
112
+ IconsResolver({
113
+ prefix: 'Icon',
114
+ }),
115
+ ],
116
+ dirs: ['src/apis/**', 'src/constants/**', 'src/composables/**', 'src/stores/**', 'src/utils/**'],
117
+ dts: 'src/auto-imports.d.ts',
118
+ vueTemplate: true,
119
+ }),
120
+ // https://github.com/unplugin/unplugin-vue-components
121
+ Components({
122
+ resolvers: [
123
+ ElementPlusResolver({ importStyle: false }),
124
+ NikoyoSPAComponentsResolver(),
125
+ IconsResolver({
126
+ enabledCollections: ['ep', 'mdi', 'carbon'],
127
+ customCollections: ['custom', 'nikoyo'],
128
+ }),
129
+ ],
130
+ extensions: ['vue'],
131
+ include: [/\.vue$/, /\.vue\?vue/],
132
+ dts: 'src/components.d.ts',
133
+ }),
134
+ // https://github.com/unplugin/unplugin-icons
135
+ Icons({
136
+ autoInstall: true,
137
+ customCollections: {
138
+ custom: FileSystemIconLoader(
139
+ path.resolve(process.cwd(), './src/assets/icons'),
140
+ svg => svg.replace(/^<svg /, '<svg fill="currentColor" '),
141
+ ),
142
+ nikoyo: async (iconName) => {
143
+ const icons = await import('@nikoyo-spa/icons')
144
+ // @ts-ignore
145
+ const icon = icons.default?.[kebabToPascalCase(iconName)]
146
+ if (!icon) {
147
+ throw new Error(`[nikoyo-icons] Icon "${iconName}" not found`)
148
+ }
149
+
150
+ return renderAntdAstToSvg(icon.icon)
151
+ },
152
+ },
153
+ }),
154
+ // https://github.com/feat-agency/vite-plugin-webfont-dl
155
+ WebfontDownload(),
156
+ // https://github.com/nonzzz/vite-plugin-compression
157
+ compression(),
158
+ // https://github.com/vuejs/devtools
159
+ VueDevTools(),
160
+ // https://github.com/WJSoftware/vite-plugin-single-spa
161
+ VitePluginSingleSpa(singleSpaConfig),
162
+ ],
163
+ build: {
164
+ rollupOptions: {
165
+ external: VITE_BUILD_EXTERNAL,
166
+ },
167
+ cssCodeSplit: true,
168
+ esbuild: isBuild
169
+ ? { drop: ['console', 'debugger'] }
170
+ : {},
171
+ },
172
+ server: {
173
+ hmr: true,
174
+ host: true,
175
+ port,
176
+ proxy: {
177
+ '/svc': VITE_PROXY_HOST,
178
+ '/token': VITE_PROXY_HOST,
179
+ '/login': VITE_PROXY_HOST,
180
+ '/pub': VITE_PROXY_HOST,
181
+ },
182
+ },
183
+ },
184
+ userConfig,
185
+ )
186
+ })
187
+ }
188
+
189
+ function kebabToPascalCase(str: string) {
190
+ return str
191
+ .split('-')
192
+ .map(s => s.charAt(0).toUpperCase() + s.slice(1))
193
+ .join('')
194
+ }
195
+
196
+ function renderAntdAstToSvg(icon: any): string {
197
+ const { tag, attrs = {}, children = [] } = icon
198
+
199
+ return `
200
+ <svg
201
+ ${renderAttrs({
202
+ ...attrs,
203
+ fill: 'currentColor',
204
+ xmlns: 'http://www.w3.org/2000/svg',
205
+ })}
206
+ >
207
+ ${children.map(renderNode).join('')}
208
+ </svg>
209
+ `
210
+ }
211
+
212
+ function renderNode(node: any): string {
213
+ const { tag, attrs = {}, children = [] } = node
214
+ return `
215
+ <${tag} ${renderAttrs(attrs)}>
216
+ ${children.map(renderNode).join('')}
217
+ </${tag}>
218
+ `
219
+ }
220
+
221
+ function renderAttrs(attrs: Record<string, any>) {
222
+ return Object.entries(attrs)
223
+ .map(([k, v]) => `${k}="${v}"`)
224
+ .join(' ')
225
+ }
226
+
227
+ export { defineConfig }
package/tsconfig.json CHANGED
@@ -34,7 +34,8 @@
34
34
  "isolatedModules": true,
35
35
  "verbatimModuleSyntax": true,
36
36
  "skipLibCheck": true,
37
- "preserveWatchOutput": true
37
+ "preserveWatchOutput": true,
38
+ "ignoreDeprecations": "6.0"
38
39
  },
39
40
  "include": ["src"],
40
41
  "exclude": ["node_modules"]
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export * from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
2
- export { default } from "D:/Dev/project/UCPX/wh-spa/nikoyo-spa-client/internal/vite-config/src/index.js";
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg id="_图层_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1024 1024">
3
- <!-- Generator: Adobe Illustrator 29.8.2, SVG Export Plug-In . SVG Version: 2.1.1 Build 3) -->
4
- <rect x="256" y="536" width="512" height="40"/>
5
- <rect x="416" y="280" width="192" height="40"/>
6
- <rect x="416" y="192" width="192" height="40"/>
7
- <path d="M279.28,447.99h465.45c12.85,0,23.27-7.81,23.27-17.45V81.45c0-9.64-10.42-17.45-23.27-17.45h-465.45c-12.85,0-23.27,7.81-23.27,17.45v349.09c0,9.64,10.42,17.45,23.27,17.45ZM320,128h384v256h-384V128Z"/>
8
- <path d="M832,256v168l64,216h-192v48.1c0,8.78-7.12,15.9-15.9,15.9h-352.19c-8.78,0-15.9-7.12-15.9-15.9v-48.1h-192.01l64-216v-168l-128,384v256c0,35.35,28.65,64,64,64h768c35.35,0,64-28.65,64-64v-256l-128-384ZM896,768v97c0,17.12-13.88,31-31,31H159c-17.12,0-31-13.88-31-31v-161h128c0,35.35,28.65,64,64,64h384c35.35,0,64-28.65,64-64h128v64Z"/>
9
- </svg>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg id="_图层_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1024 1024">
3
- <!-- Generator: Adobe Illustrator 29.8.2, SVG Export Plug-In . SVG Version: 2.1.1 Build 3) -->
4
- <path d="M928,64H352c-17.67,0-32,14.33-32,32v96h64v-64h512v287.97h64V96c0-17.67-14.33-32-32-32Z"/>
5
- <rect x="256" y="480" width="192" height="64"/>
6
- <rect x="256" y="672" width="128" height="64"/>
7
- <path d="M704,448c-141.38,0-256,114.62-256,256s114.62,256,256,256,256-114.62,256-256-114.62-256-256-256ZM512,704c0-41.47,13.15-79.86,35.5-111.25l267.75,267.75c-31.39,22.35-69.78,35.5-111.25,35.5-106.04,0-192-85.96-192-192ZM860.5,815.25l-267.75-267.75c31.39-22.35,69.78-35.5,111.25-35.5,106.04,0,192,85.96,192,192,0,41.47-13.15,79.86-35.5,111.25Z"/>
8
- <path d="M376,896h-248V320h576v64h64v-96c0-17.67-14.33-32-32-32H96c-17.67,0-32,14.33-32,32v640c0,17.67,14.33,32,32,32h352v-64h-72Z"/>
9
- </svg>
@@ -1,110 +0,0 @@
1
- import path from 'node:path'
2
- import { VITE_BUILD_EXTERNAL } from '@nikoyo-spa/import-map-shared'
3
- import { NikoyoSPAComponentsResolver, NikoyoSPACoreResolver } from '@nikoyo-spa/resolvers'
4
- import tailwindcss from '@tailwindcss/vite'
5
- import { unheadVueComposablesImports } from '@unhead/vue'
6
- import vue from '@vitejs/plugin-vue'
7
- import AutoImport from 'unplugin-auto-import/vite'
8
- import IconsResolver from 'unplugin-icons/resolver'
9
- import Icons from 'unplugin-icons/vite'
10
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
11
- import Components from 'unplugin-vue-components/vite'
12
- import { VueRouterAutoImports } from 'unplugin-vue-router'
13
- import VueRouter from 'unplugin-vue-router/vite'
14
- import { defineConfig } from 'vite'
15
- import { compression } from 'vite-plugin-compression2'
16
- import VueDevTools from 'vite-plugin-vue-devtools'
17
- import Layouts from 'vite-plugin-vue-layouts'
18
- import WebfontDownload from 'vite-plugin-webfont-dl'
19
- import { FileSystemIconLoader } from 'unplugin-icons/loaders'
20
-
21
- export const viteConfig = defineConfig({
22
- resolve: {
23
- alias: {
24
- '@': path.resolve(process.cwd(), './src'),
25
- },
26
- },
27
- build: {
28
- rollupOptions: {
29
- external: VITE_BUILD_EXTERNAL,
30
- },
31
- },
32
- plugins: [
33
- // https://github.com/vitejs/vite-plugin-vue
34
- vue(),
35
- // https://github.com/posva/unplugin-vue-router
36
- VueRouter({
37
- extensions: ['.vue'],
38
- dts: 'src/typed-router.d.ts',
39
- }),
40
- // https://github.com/johncampionjr/vite-plugin-vue-layouts
41
- Layouts(),
42
- // https://github.com/tailwindlabs/tailwindcss
43
- tailwindcss(),
44
- // https://github.com/unplugin/unplugin-auto-import
45
- AutoImport({
46
- imports: [
47
- 'vue',
48
- 'vue-i18n',
49
- '@vueuse/core',
50
- 'pinia',
51
- unheadVueComposablesImports,
52
- VueRouterAutoImports,
53
- NikoyoSPACoreResolver(),
54
- {
55
- 'vue-router/auto': ['useLink'],
56
- 'element-plus': ['ElMessage', 'ElLoading'],
57
- },
58
- ],
59
- resolvers: [
60
- ElementPlusResolver({ importStyle: false }),
61
- IconsResolver({
62
- prefix: 'Icon',
63
- }),
64
- ],
65
- dirs: ['src/apis/**', 'src/constants/**', 'src/composables/**', 'src/stores/**', 'src/utils/**'],
66
- dts: 'src/auto-imports.d.ts',
67
- vueTemplate: true,
68
- }),
69
- // https://github.com/unplugin/unplugin-vue-components
70
- Components({
71
- resolvers: [
72
- ElementPlusResolver({ importStyle: false }),
73
- NikoyoSPAComponentsResolver(),
74
- IconsResolver({
75
- enabledCollections: ['ep', 'mdi', 'carbon'],
76
- customCollections: ['custom','global']
77
- }),
78
- ],
79
- extensions: ['vue'],
80
- include: [/\.vue$/, /\.vue\?vue/],
81
- dts: 'src/components.d.ts',
82
- }),
83
- // https://github.com/unplugin/unplugin-icons
84
- Icons({
85
- autoInstall: true,
86
- customCollections: {
87
- 'custom': FileSystemIconLoader(
88
- path.resolve(process.cwd(), './src/assets/icons'),
89
- svg => svg.replace(/^<svg /, '<svg fill="currentColor" '),
90
- ),
91
- 'global': FileSystemIconLoader(
92
- path.resolve(__dirname,"assets/icons"),
93
- svg => svg.replace(/^<svg /, '<svg fill="currentColor" '),
94
- ),
95
- }
96
- }),
97
- // https://github.com/feat-agency/vite-plugin-webfont-dl
98
- WebfontDownload(),
99
- // https://github.com/nonzzz/vite-plugin-compression
100
- compression(),
101
- // https://github.com/vuejs/devtools
102
- VueDevTools(),
103
- ],
104
- server: {
105
- hmr: true,
106
- host: true,
107
- },
108
- })
109
-
110
- export default viteConfig
package/tsdown.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'tsdown'
2
-
3
- export default defineConfig({
4
- entry: [
5
- 'src/index.ts',
6
- ],
7
- shims: true,
8
- format: ['esm'],
9
- })