@halo-dev/ui-plugin-bundler-kit 2.21.1 → 2.21.2
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/README.md +15 -15
- package/dist/index.d.ts +50 -48
- package/dist/index.js +218 -0
- package/package.json +11 -16
- package/src/constants/build.ts +4 -0
- package/src/constants/externals.ts +16 -0
- package/src/constants/halo-plugin.ts +3 -0
- package/src/index.ts +3 -0
- package/src/legacy.ts +69 -0
- package/src/rsbuild.ts +146 -0
- package/src/utils/halo-plugin.ts +11 -0
- package/src/vite.ts +85 -0
- package/tsconfig.json +18 -0
- package/tsdown.config.ts +10 -0
- package/dist/index.d.mts +0 -75
- package/dist/index.mjs +0 -213
package/README.md
CHANGED
|
@@ -273,20 +273,20 @@ Both Vite and Rsbuild are excellent build tools, but they have different strengt
|
|
|
273
273
|
**Example with dynamic imports:**
|
|
274
274
|
|
|
275
275
|
```typescript
|
|
276
|
-
import { definePlugin } from
|
|
277
|
-
import { defineAsyncComponent } from
|
|
278
|
-
import { VLoading } from
|
|
276
|
+
import { definePlugin } from "@halo-dev/console-shared";
|
|
277
|
+
import { defineAsyncComponent } from "vue";
|
|
278
|
+
import { VLoading } from "@halo-dev/components";
|
|
279
279
|
|
|
280
280
|
export default definePlugin({
|
|
281
281
|
routes: [
|
|
282
282
|
{
|
|
283
|
-
parentName:
|
|
283
|
+
parentName: "Root",
|
|
284
284
|
route: {
|
|
285
|
-
path:
|
|
286
|
-
name:
|
|
285
|
+
path: "demo",
|
|
286
|
+
name: "DemoPage",
|
|
287
287
|
// Lazy load heavy components
|
|
288
288
|
component: defineAsyncComponent({
|
|
289
|
-
loader: () => import(
|
|
289
|
+
loader: () => import("./views/DemoPage.vue"),
|
|
290
290
|
loadingComponent: VLoading,
|
|
291
291
|
}),
|
|
292
292
|
},
|
|
@@ -306,14 +306,14 @@ export default definePlugin({
|
|
|
306
306
|
|
|
307
307
|
### Summary
|
|
308
308
|
|
|
309
|
-
| Feature
|
|
310
|
-
|
|
311
|
-
| Code Splitting
|
|
312
|
-
| Vue Ecosystem
|
|
313
|
-
| Build Performance | ✅ Good
|
|
314
|
-
| Dev Experience
|
|
315
|
-
| Plugin Ecosystem
|
|
316
|
-
| Configuration
|
|
309
|
+
| Feature | Vite | Rsbuild |
|
|
310
|
+
| ----------------- | ------------ | ------------ |
|
|
311
|
+
| Code Splitting | ❌ Limited | ✅ Excellent |
|
|
312
|
+
| Vue Ecosystem | ✅ Excellent | ✅ Good |
|
|
313
|
+
| Build Performance | ✅ Good | ✅ Excellent |
|
|
314
|
+
| Dev Experience | ✅ Excellent | ✅ Excellent |
|
|
315
|
+
| Plugin Ecosystem | ✅ Rich | ✅ Growing |
|
|
316
|
+
| Configuration | ✅ Simple | ⚖️ Moderate |
|
|
317
317
|
|
|
318
318
|
**Recommendation**: Use **Rsbuild** for complex plugins with large frontend codebases, and **Vite** for simpler plugins or when you need extensive Vue ecosystem integration.
|
|
319
319
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { RsbuildConfig, ConfigParams } from '@rsbuild/core';
|
|
1
|
+
import { ConfigParams, RsbuildConfig } from "@rsbuild/core";
|
|
2
|
+
import { Plugin, UserConfig, UserConfigFnObject } from "vite";
|
|
4
3
|
|
|
4
|
+
//#region src/legacy.d.ts
|
|
5
5
|
interface HaloUIPluginBundlerKitOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
outDir?: string | {
|
|
7
|
+
dev: string;
|
|
8
|
+
prod: string;
|
|
9
|
+
};
|
|
10
|
+
manifestPath?: string;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* @deprecated Use `viteConfig` or `rsbuildConfig` instead.
|
|
14
14
|
*/
|
|
15
15
|
declare function HaloUIPluginBundlerKit(options?: HaloUIPluginBundlerKitOptions): Plugin;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/rsbuild.d.ts
|
|
18
|
+
interface RsBuildUserConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Halo plugin manifest path.
|
|
21
|
+
*
|
|
22
|
+
* @default "../src/main/resources/plugin.yaml"
|
|
23
|
+
*/
|
|
24
|
+
manifestPath?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Custom Rsbuild config.
|
|
27
|
+
*/
|
|
28
|
+
rsbuild: RsbuildConfig | ((env: ConfigParams) => RsbuildConfig);
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Rsbuild config for Halo UI Plugin.
|
|
31
32
|
*
|
|
32
33
|
* @example
|
|
33
34
|
* ```ts
|
|
34
|
-
* import {
|
|
35
|
+
* import { rsbuildConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
35
36
|
*
|
|
36
|
-
* export default
|
|
37
|
-
*
|
|
38
|
-
* // your custom
|
|
37
|
+
* export default rsbuildConfig({
|
|
38
|
+
* rsbuild: {
|
|
39
|
+
* // your custom rsbuild config
|
|
39
40
|
* },
|
|
40
41
|
* });
|
|
41
42
|
* ```
|
|
43
|
+
* @param config
|
|
44
|
+
* @returns
|
|
42
45
|
*/
|
|
43
|
-
declare function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
declare function rsbuildConfig(config?: RsBuildUserConfig): (env: ConfigParams) => RsbuildConfig;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/vite.d.ts
|
|
49
|
+
interface ViteUserConfig {
|
|
50
|
+
/**
|
|
51
|
+
* Halo plugin manifest path.
|
|
52
|
+
*
|
|
53
|
+
* @default "../src/main/resources/plugin.yaml"
|
|
54
|
+
*/
|
|
55
|
+
manifestPath?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom Vite config.
|
|
58
|
+
*/
|
|
59
|
+
vite: UserConfig | UserConfigFnObject;
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
|
-
*
|
|
62
|
+
* Vite config for Halo UI Plugin.
|
|
59
63
|
*
|
|
60
64
|
* @example
|
|
61
65
|
* ```ts
|
|
62
|
-
* import {
|
|
66
|
+
* import { viteConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
63
67
|
*
|
|
64
|
-
* export default
|
|
65
|
-
*
|
|
66
|
-
* // your custom
|
|
68
|
+
* export default viteConfig({
|
|
69
|
+
* vite: {
|
|
70
|
+
* // your custom vite config
|
|
67
71
|
* },
|
|
68
72
|
* });
|
|
69
73
|
* ```
|
|
70
|
-
* @param config
|
|
71
|
-
* @returns
|
|
72
74
|
*/
|
|
73
|
-
declare function
|
|
74
|
-
|
|
75
|
-
export { HaloUIPluginBundlerKit, rsbuildConfig, viteConfig };
|
|
75
|
+
declare function viteConfig(config?: ViteUserConfig): UserConfigFnObject;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { HaloUIPluginBundlerKit, rsbuildConfig, viteConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import yaml from "js-yaml";
|
|
3
|
+
import { defineConfig, mergeRsbuildConfig } from "@rsbuild/core";
|
|
4
|
+
import { pluginVue } from "@rsbuild/plugin-vue";
|
|
5
|
+
import Vue from "@vitejs/plugin-vue";
|
|
6
|
+
import { defineConfig as defineConfig$1, mergeConfig } from "vite";
|
|
7
|
+
|
|
8
|
+
//#region src/constants/build.ts
|
|
9
|
+
const DEFAULT_OUT_DIR_DEV = "../build/resources/main/console";
|
|
10
|
+
const DEFAULT_OUT_DIR_PROD = "./build/dist";
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/constants/externals.ts
|
|
14
|
+
const GLOBALS = {
|
|
15
|
+
vue: "Vue",
|
|
16
|
+
"vue-router": "VueRouter",
|
|
17
|
+
"@vueuse/core": "VueUse",
|
|
18
|
+
"@vueuse/components": "VueUse",
|
|
19
|
+
"@vueuse/router": "VueUse",
|
|
20
|
+
"@halo-dev/console-shared": "HaloConsoleShared",
|
|
21
|
+
"@halo-dev/components": "HaloComponents",
|
|
22
|
+
"@halo-dev/api-client": "HaloApiClient",
|
|
23
|
+
"@halo-dev/richtext-editor": "RichTextEditor",
|
|
24
|
+
axios: "axios"
|
|
25
|
+
};
|
|
26
|
+
const EXTERNALS = Object.keys(GLOBALS);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/constants/halo-plugin.ts
|
|
30
|
+
const DEFAULT_MANIFEST_PATH = "../src/main/resources/plugin.yaml";
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/utils/halo-plugin.ts
|
|
34
|
+
function getHaloPluginManifest(manifestPath) {
|
|
35
|
+
const manifest = yaml.load(fs.readFileSync(manifestPath, "utf8"));
|
|
36
|
+
return manifest;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/legacy.ts
|
|
41
|
+
const LEGACY_OUT_DIR_PROD = "../src/main/resources/console";
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `viteConfig` or `rsbuildConfig` instead.
|
|
44
|
+
*/
|
|
45
|
+
function HaloUIPluginBundlerKit(options = {}) {
|
|
46
|
+
return {
|
|
47
|
+
name: "halo-ui-plugin-bundler-kit",
|
|
48
|
+
config(config, env) {
|
|
49
|
+
const isProduction = env.mode === "production";
|
|
50
|
+
let outDir = isProduction ? LEGACY_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
51
|
+
if (options.outDir) if (typeof options.outDir === "string") outDir = options.outDir;
|
|
52
|
+
else outDir = isProduction ? options.outDir.prod : options.outDir.dev;
|
|
53
|
+
const manifestPath = options.manifestPath || DEFAULT_MANIFEST_PATH;
|
|
54
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
55
|
+
return {
|
|
56
|
+
...config,
|
|
57
|
+
define: { "process.env": process.env },
|
|
58
|
+
build: {
|
|
59
|
+
outDir,
|
|
60
|
+
emptyOutDir: true,
|
|
61
|
+
lib: {
|
|
62
|
+
entry: "src/index.ts",
|
|
63
|
+
name: manifest.metadata.name,
|
|
64
|
+
formats: ["iife"],
|
|
65
|
+
fileName: () => "main.js"
|
|
66
|
+
},
|
|
67
|
+
rollupOptions: {
|
|
68
|
+
external: EXTERNALS,
|
|
69
|
+
output: {
|
|
70
|
+
globals: GLOBALS,
|
|
71
|
+
extend: true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/rsbuild.ts
|
|
82
|
+
function createRsbuildPresetsConfig(manifestPath) {
|
|
83
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
84
|
+
return defineConfig(({ envMode }) => {
|
|
85
|
+
const isProduction = envMode === "production";
|
|
86
|
+
const outDir = isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
87
|
+
return {
|
|
88
|
+
mode: envMode || "production",
|
|
89
|
+
plugins: [pluginVue()],
|
|
90
|
+
source: { entry: { main: "./src/index.ts" } },
|
|
91
|
+
dev: { hmr: false },
|
|
92
|
+
performance: { chunkSplit: { strategy: "custom" } },
|
|
93
|
+
tools: {
|
|
94
|
+
rspack: {
|
|
95
|
+
optimization: {
|
|
96
|
+
splitChunks: { chunks: "async" },
|
|
97
|
+
moduleIds: "named"
|
|
98
|
+
},
|
|
99
|
+
experiments: { rspackFuture: { bundlerInfo: { force: false } } },
|
|
100
|
+
module: { parser: { javascript: { importMeta: false } } },
|
|
101
|
+
output: {
|
|
102
|
+
publicPath: `/plugins/${manifest.metadata.name}/assets/console/`,
|
|
103
|
+
library: {
|
|
104
|
+
type: "window",
|
|
105
|
+
export: "default",
|
|
106
|
+
name: manifest.metadata.name
|
|
107
|
+
},
|
|
108
|
+
globalObject: "window",
|
|
109
|
+
iife: true
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
htmlPlugin: false
|
|
113
|
+
},
|
|
114
|
+
output: {
|
|
115
|
+
distPath: {
|
|
116
|
+
root: outDir,
|
|
117
|
+
js: "",
|
|
118
|
+
css: "",
|
|
119
|
+
jsAsync: "chunks",
|
|
120
|
+
cssAsync: "chunks"
|
|
121
|
+
},
|
|
122
|
+
cleanDistPath: true,
|
|
123
|
+
filename: {
|
|
124
|
+
css: (pathData) => {
|
|
125
|
+
if (pathData.chunk?.name === "main") return "style.css";
|
|
126
|
+
return "[name].[contenthash:8].css";
|
|
127
|
+
},
|
|
128
|
+
js: (pathData) => {
|
|
129
|
+
if (pathData.chunk?.name === "main") return "main.js";
|
|
130
|
+
return "[name].[contenthash:8].js";
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
externals: GLOBALS
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Rsbuild config for Halo UI Plugin.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { rsbuildConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
144
|
+
*
|
|
145
|
+
* export default rsbuildConfig({
|
|
146
|
+
* rsbuild: {
|
|
147
|
+
* // your custom rsbuild config
|
|
148
|
+
* },
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
* @param config
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
function rsbuildConfig(config) {
|
|
155
|
+
const presetsConfigFn = createRsbuildPresetsConfig(config?.manifestPath || DEFAULT_MANIFEST_PATH);
|
|
156
|
+
return defineConfig((env) => {
|
|
157
|
+
const presetsConfig = presetsConfigFn(env);
|
|
158
|
+
const userConfig = typeof config?.rsbuild === "function" ? config.rsbuild(env) : config?.rsbuild || {};
|
|
159
|
+
return mergeRsbuildConfig(presetsConfig, userConfig);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/vite.ts
|
|
165
|
+
function createVitePresetsConfig(manifestPath) {
|
|
166
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
167
|
+
return defineConfig$1(({ mode }) => {
|
|
168
|
+
const isProduction = mode === "production";
|
|
169
|
+
return {
|
|
170
|
+
mode: mode || "production",
|
|
171
|
+
plugins: [Vue()],
|
|
172
|
+
define: { "process.env.NODE_ENV": "'production'" },
|
|
173
|
+
build: {
|
|
174
|
+
outDir: isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV,
|
|
175
|
+
emptyOutDir: true,
|
|
176
|
+
lib: {
|
|
177
|
+
entry: "src/index.ts",
|
|
178
|
+
name: manifest.metadata.name,
|
|
179
|
+
formats: ["iife"],
|
|
180
|
+
fileName: () => "main.js",
|
|
181
|
+
cssFileName: "style"
|
|
182
|
+
},
|
|
183
|
+
rollupOptions: {
|
|
184
|
+
external: EXTERNALS,
|
|
185
|
+
output: {
|
|
186
|
+
globals: GLOBALS,
|
|
187
|
+
extend: true
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Vite config for Halo UI Plugin.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { viteConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
200
|
+
*
|
|
201
|
+
* export default viteConfig({
|
|
202
|
+
* vite: {
|
|
203
|
+
* // your custom vite config
|
|
204
|
+
* },
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
function viteConfig(config) {
|
|
209
|
+
const presetsConfigFn = createVitePresetsConfig(config?.manifestPath || DEFAULT_MANIFEST_PATH);
|
|
210
|
+
return defineConfig$1((env) => {
|
|
211
|
+
const presetsConfig = presetsConfigFn(env);
|
|
212
|
+
const userConfig = typeof config?.vite === "function" ? config.vite(env) : config?.vite || {};
|
|
213
|
+
return mergeConfig(presetsConfig, userConfig);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
export { HaloUIPluginBundlerKit, rsbuildConfig, viteConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halo-dev/ui-plugin-bundler-kit",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.2",
|
|
4
4
|
"homepage": "https://github.com/halo-dev/halo/tree/main/ui/packages/ui-plugin-bundler-kit#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/halo-dev/halo/issues"
|
|
@@ -14,35 +14,30 @@
|
|
|
14
14
|
"author": "@halo-dev",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
|
|
19
|
-
"import": "./dist/index.mjs"
|
|
20
|
-
}
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
21
19
|
},
|
|
22
|
-
"main": "./dist/index.
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
23
22
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"files": [
|
|
25
|
-
"dist"
|
|
26
|
-
],
|
|
27
23
|
"dependencies": {
|
|
28
24
|
"js-yaml": "^4.1.0",
|
|
29
|
-
"@halo-dev/api-client": "2.21.
|
|
25
|
+
"@halo-dev/api-client": "2.21.1"
|
|
30
26
|
},
|
|
31
27
|
"devDependencies": {
|
|
32
|
-
"@types/js-yaml": "^4.0.9"
|
|
33
|
-
"unbuild": "^3.5.0"
|
|
28
|
+
"@types/js-yaml": "^4.0.9"
|
|
34
29
|
},
|
|
35
30
|
"peerDependencies": {
|
|
36
31
|
"@rsbuild/core": "^1.0.0",
|
|
37
32
|
"@rsbuild/plugin-vue": "^1.0.0",
|
|
38
|
-
"@vitejs/plugin-vue": "^
|
|
39
|
-
"vite": "^
|
|
33
|
+
"@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
|
|
34
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
40
35
|
},
|
|
41
36
|
"engines": {
|
|
42
37
|
"node": "^18.0.0 || >=20.0.0"
|
|
43
38
|
},
|
|
44
39
|
"scripts": {
|
|
45
|
-
"build": "
|
|
46
|
-
"dev": "
|
|
40
|
+
"build": "tsdown",
|
|
41
|
+
"dev": "tsdown --watch"
|
|
47
42
|
}
|
|
48
43
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const GLOBALS = {
|
|
2
|
+
vue: "Vue",
|
|
3
|
+
"vue-router": "VueRouter",
|
|
4
|
+
"@vueuse/core": "VueUse",
|
|
5
|
+
"@vueuse/components": "VueUse",
|
|
6
|
+
"@vueuse/router": "VueUse",
|
|
7
|
+
"@halo-dev/console-shared": "HaloConsoleShared",
|
|
8
|
+
"@halo-dev/components": "HaloComponents",
|
|
9
|
+
"@halo-dev/api-client": "HaloApiClient",
|
|
10
|
+
"@halo-dev/richtext-editor": "RichTextEditor",
|
|
11
|
+
axios: "axios",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const EXTERNALS = Object.keys(GLOBALS) as string[];
|
|
15
|
+
|
|
16
|
+
export { EXTERNALS, GLOBALS };
|
package/src/index.ts
ADDED
package/src/legacy.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { DEFAULT_OUT_DIR_DEV } from "./constants/build";
|
|
3
|
+
import { EXTERNALS, GLOBALS } from "./constants/externals";
|
|
4
|
+
import { DEFAULT_MANIFEST_PATH } from "./constants/halo-plugin";
|
|
5
|
+
import { getHaloPluginManifest } from "./utils/halo-plugin";
|
|
6
|
+
|
|
7
|
+
const LEGACY_OUT_DIR_PROD = "../src/main/resources/console";
|
|
8
|
+
|
|
9
|
+
interface HaloUIPluginBundlerKitOptions {
|
|
10
|
+
outDir?:
|
|
11
|
+
| string
|
|
12
|
+
| {
|
|
13
|
+
dev: string;
|
|
14
|
+
prod: string;
|
|
15
|
+
};
|
|
16
|
+
manifestPath?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `viteConfig` or `rsbuildConfig` instead.
|
|
21
|
+
*/
|
|
22
|
+
export function HaloUIPluginBundlerKit(
|
|
23
|
+
options: HaloUIPluginBundlerKitOptions = {}
|
|
24
|
+
): Plugin {
|
|
25
|
+
return {
|
|
26
|
+
name: "halo-ui-plugin-bundler-kit",
|
|
27
|
+
config(config, env) {
|
|
28
|
+
const isProduction = env.mode === "production";
|
|
29
|
+
|
|
30
|
+
let outDir = isProduction ? LEGACY_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
31
|
+
|
|
32
|
+
if (options.outDir) {
|
|
33
|
+
if (typeof options.outDir === "string") {
|
|
34
|
+
outDir = options.outDir;
|
|
35
|
+
} else {
|
|
36
|
+
outDir = isProduction ? options.outDir.prod : options.outDir.dev;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const manifestPath = options.manifestPath || DEFAULT_MANIFEST_PATH;
|
|
41
|
+
|
|
42
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...config,
|
|
46
|
+
define: {
|
|
47
|
+
"process.env": process.env,
|
|
48
|
+
},
|
|
49
|
+
build: {
|
|
50
|
+
outDir,
|
|
51
|
+
emptyOutDir: true,
|
|
52
|
+
lib: {
|
|
53
|
+
entry: "src/index.ts",
|
|
54
|
+
name: manifest.metadata.name,
|
|
55
|
+
formats: ["iife"],
|
|
56
|
+
fileName: () => "main.js",
|
|
57
|
+
},
|
|
58
|
+
rollupOptions: {
|
|
59
|
+
external: EXTERNALS,
|
|
60
|
+
output: {
|
|
61
|
+
globals: GLOBALS,
|
|
62
|
+
extend: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
package/src/rsbuild.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineConfig,
|
|
3
|
+
mergeRsbuildConfig,
|
|
4
|
+
type ConfigParams,
|
|
5
|
+
type RsbuildConfig,
|
|
6
|
+
type RsbuildMode,
|
|
7
|
+
} from "@rsbuild/core";
|
|
8
|
+
import { pluginVue } from "@rsbuild/plugin-vue";
|
|
9
|
+
import { DEFAULT_OUT_DIR_DEV, DEFAULT_OUT_DIR_PROD } from "./constants/build";
|
|
10
|
+
import { GLOBALS } from "./constants/externals";
|
|
11
|
+
import { DEFAULT_MANIFEST_PATH } from "./constants/halo-plugin";
|
|
12
|
+
import { getHaloPluginManifest } from "./utils/halo-plugin";
|
|
13
|
+
|
|
14
|
+
export interface RsBuildUserConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Halo plugin manifest path.
|
|
17
|
+
*
|
|
18
|
+
* @default "../src/main/resources/plugin.yaml"
|
|
19
|
+
*/
|
|
20
|
+
manifestPath?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Custom Rsbuild config.
|
|
24
|
+
*/
|
|
25
|
+
rsbuild: RsbuildConfig | ((env: ConfigParams) => RsbuildConfig);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createRsbuildPresetsConfig(manifestPath: string) {
|
|
29
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
30
|
+
|
|
31
|
+
return defineConfig(({ envMode }) => {
|
|
32
|
+
const isProduction = envMode === "production";
|
|
33
|
+
|
|
34
|
+
const outDir = isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
mode: (envMode as RsbuildMode) || "production",
|
|
38
|
+
plugins: [pluginVue()],
|
|
39
|
+
source: {
|
|
40
|
+
entry: {
|
|
41
|
+
main: "./src/index.ts",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
dev: {
|
|
45
|
+
hmr: false,
|
|
46
|
+
},
|
|
47
|
+
performance: {
|
|
48
|
+
chunkSplit: {
|
|
49
|
+
strategy: "custom",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
tools: {
|
|
53
|
+
rspack: {
|
|
54
|
+
optimization: {
|
|
55
|
+
splitChunks: {
|
|
56
|
+
chunks: "async",
|
|
57
|
+
},
|
|
58
|
+
moduleIds: "named",
|
|
59
|
+
},
|
|
60
|
+
experiments: {
|
|
61
|
+
rspackFuture: {
|
|
62
|
+
bundlerInfo: {
|
|
63
|
+
force: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
module: {
|
|
68
|
+
parser: {
|
|
69
|
+
javascript: {
|
|
70
|
+
importMeta: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
output: {
|
|
75
|
+
publicPath: `/plugins/${manifest.metadata.name}/assets/console/`,
|
|
76
|
+
library: {
|
|
77
|
+
type: "window",
|
|
78
|
+
export: "default",
|
|
79
|
+
name: manifest.metadata.name,
|
|
80
|
+
},
|
|
81
|
+
globalObject: "window",
|
|
82
|
+
iife: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
htmlPlugin: false,
|
|
86
|
+
},
|
|
87
|
+
output: {
|
|
88
|
+
distPath: {
|
|
89
|
+
root: outDir,
|
|
90
|
+
js: "",
|
|
91
|
+
css: "",
|
|
92
|
+
jsAsync: "chunks",
|
|
93
|
+
cssAsync: "chunks",
|
|
94
|
+
},
|
|
95
|
+
cleanDistPath: true,
|
|
96
|
+
filename: {
|
|
97
|
+
css: (pathData) => {
|
|
98
|
+
if (pathData.chunk?.name === "main") {
|
|
99
|
+
return "style.css";
|
|
100
|
+
}
|
|
101
|
+
return "[name].[contenthash:8].css";
|
|
102
|
+
},
|
|
103
|
+
js: (pathData) => {
|
|
104
|
+
if (pathData.chunk?.name === "main") {
|
|
105
|
+
return "main.js";
|
|
106
|
+
}
|
|
107
|
+
return "[name].[contenthash:8].js";
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
externals: GLOBALS,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Rsbuild config for Halo UI Plugin.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { rsbuildConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
122
|
+
*
|
|
123
|
+
* export default rsbuildConfig({
|
|
124
|
+
* rsbuild: {
|
|
125
|
+
* // your custom rsbuild config
|
|
126
|
+
* },
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
* @param config
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
export function rsbuildConfig(
|
|
133
|
+
config?: RsBuildUserConfig
|
|
134
|
+
): (env: ConfigParams) => RsbuildConfig {
|
|
135
|
+
const presetsConfigFn = createRsbuildPresetsConfig(
|
|
136
|
+
config?.manifestPath || DEFAULT_MANIFEST_PATH
|
|
137
|
+
);
|
|
138
|
+
return defineConfig((env) => {
|
|
139
|
+
const presetsConfig = presetsConfigFn(env);
|
|
140
|
+
const userConfig =
|
|
141
|
+
typeof config?.rsbuild === "function"
|
|
142
|
+
? config.rsbuild(env)
|
|
143
|
+
: config?.rsbuild || {};
|
|
144
|
+
return mergeRsbuildConfig(presetsConfig, userConfig);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin as HaloPlugin } from "@halo-dev/api-client";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
|
|
5
|
+
export function getHaloPluginManifest(manifestPath: string) {
|
|
6
|
+
const manifest = yaml.load(
|
|
7
|
+
fs.readFileSync(manifestPath, "utf8")
|
|
8
|
+
) as HaloPlugin;
|
|
9
|
+
|
|
10
|
+
return manifest;
|
|
11
|
+
}
|
package/src/vite.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import Vue from "@vitejs/plugin-vue";
|
|
2
|
+
import {
|
|
3
|
+
defineConfig,
|
|
4
|
+
mergeConfig,
|
|
5
|
+
UserConfig,
|
|
6
|
+
UserConfigFnObject,
|
|
7
|
+
} from "vite";
|
|
8
|
+
import { DEFAULT_OUT_DIR_DEV, DEFAULT_OUT_DIR_PROD } from "./constants/build";
|
|
9
|
+
import { EXTERNALS, GLOBALS } from "./constants/externals";
|
|
10
|
+
import { DEFAULT_MANIFEST_PATH } from "./constants/halo-plugin";
|
|
11
|
+
import { getHaloPluginManifest } from "./utils/halo-plugin";
|
|
12
|
+
|
|
13
|
+
export interface ViteUserConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Halo plugin manifest path.
|
|
16
|
+
*
|
|
17
|
+
* @default "../src/main/resources/plugin.yaml"
|
|
18
|
+
*/
|
|
19
|
+
manifestPath?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Custom Vite config.
|
|
23
|
+
*/
|
|
24
|
+
vite: UserConfig | UserConfigFnObject;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function createVitePresetsConfig(manifestPath: string) {
|
|
28
|
+
const manifest = getHaloPluginManifest(manifestPath);
|
|
29
|
+
|
|
30
|
+
return defineConfig(({ mode }) => {
|
|
31
|
+
const isProduction = mode === "production";
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
mode: mode || "production",
|
|
35
|
+
plugins: [Vue()],
|
|
36
|
+
define: { "process.env.NODE_ENV": "'production'" },
|
|
37
|
+
build: {
|
|
38
|
+
outDir: isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV,
|
|
39
|
+
emptyOutDir: true,
|
|
40
|
+
lib: {
|
|
41
|
+
entry: "src/index.ts",
|
|
42
|
+
name: manifest.metadata.name,
|
|
43
|
+
formats: ["iife"],
|
|
44
|
+
fileName: () => "main.js",
|
|
45
|
+
cssFileName: "style",
|
|
46
|
+
},
|
|
47
|
+
rollupOptions: {
|
|
48
|
+
external: EXTERNALS,
|
|
49
|
+
output: {
|
|
50
|
+
globals: GLOBALS,
|
|
51
|
+
extend: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Vite config for Halo UI Plugin.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { viteConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
65
|
+
*
|
|
66
|
+
* export default viteConfig({
|
|
67
|
+
* vite: {
|
|
68
|
+
* // your custom vite config
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function viteConfig(config?: ViteUserConfig) {
|
|
74
|
+
const presetsConfigFn = createVitePresetsConfig(
|
|
75
|
+
config?.manifestPath || DEFAULT_MANIFEST_PATH
|
|
76
|
+
);
|
|
77
|
+
return defineConfig((env) => {
|
|
78
|
+
const presetsConfig = presetsConfigFn(env);
|
|
79
|
+
const userConfig =
|
|
80
|
+
typeof config?.vite === "function"
|
|
81
|
+
? config.vite(env)
|
|
82
|
+
: config?.vite || {};
|
|
83
|
+
return mergeConfig(presetsConfig, userConfig);
|
|
84
|
+
});
|
|
85
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["src"],
|
|
3
|
+
"exclude": ["**/*.spec.ts"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"module": "ES2020",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"noImplicitOverride": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"resolveJsonModule": true
|
|
17
|
+
}
|
|
18
|
+
}
|
package/tsdown.config.ts
ADDED
package/dist/index.d.mts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Plugin, UserConfig, UserConfigFnObject } from 'vite';
|
|
2
|
-
import * as _rsbuild_core_dist_types_loadConfig from '@rsbuild/core/dist-types/loadConfig';
|
|
3
|
-
import { RsbuildConfig, ConfigParams } from '@rsbuild/core';
|
|
4
|
-
|
|
5
|
-
interface HaloUIPluginBundlerKitOptions {
|
|
6
|
-
outDir?: string | {
|
|
7
|
-
dev: string;
|
|
8
|
-
prod: string;
|
|
9
|
-
};
|
|
10
|
-
manifestPath?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use `viteConfig` or `rsbuildConfig` instead.
|
|
14
|
-
*/
|
|
15
|
-
declare function HaloUIPluginBundlerKit(options?: HaloUIPluginBundlerKitOptions): Plugin;
|
|
16
|
-
|
|
17
|
-
interface ViteUserConfig {
|
|
18
|
-
/**
|
|
19
|
-
* Halo plugin manifest path.
|
|
20
|
-
*
|
|
21
|
-
* @default "../src/main/resources/plugin.yaml"
|
|
22
|
-
*/
|
|
23
|
-
manifestPath?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Custom Vite config.
|
|
26
|
-
*/
|
|
27
|
-
vite: UserConfig | UserConfigFnObject;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Vite config for Halo UI Plugin.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* import { viteConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
35
|
-
*
|
|
36
|
-
* export default viteConfig({
|
|
37
|
-
* vite: {
|
|
38
|
-
* // your custom vite config
|
|
39
|
-
* },
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
declare function viteConfig(config?: ViteUserConfig): UserConfigFnObject;
|
|
44
|
-
|
|
45
|
-
interface RsBuildUserConfig {
|
|
46
|
-
/**
|
|
47
|
-
* Halo plugin manifest path.
|
|
48
|
-
*
|
|
49
|
-
* @default "../src/main/resources/plugin.yaml"
|
|
50
|
-
*/
|
|
51
|
-
manifestPath?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Custom Rsbuild config.
|
|
54
|
-
*/
|
|
55
|
-
rsbuild: RsbuildConfig | ((env: ConfigParams) => RsbuildConfig);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Rsbuild config for Halo UI Plugin.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* import { rsbuildConfig } from "@halo-dev/ui-plugin-bundler-kit";
|
|
63
|
-
*
|
|
64
|
-
* export default rsbuildConfig({
|
|
65
|
-
* rsbuild: {
|
|
66
|
-
* // your custom rsbuild config
|
|
67
|
-
* },
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
* @param config
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
declare function rsbuildConfig(config?: RsBuildUserConfig): _rsbuild_core_dist_types_loadConfig.RsbuildConfigSyncFn;
|
|
74
|
-
|
|
75
|
-
export { HaloUIPluginBundlerKit, rsbuildConfig, viteConfig };
|
package/dist/index.mjs
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import yaml from 'js-yaml';
|
|
3
|
-
import { defineConfig, mergeConfig } from 'vite';
|
|
4
|
-
import Vue from '@vitejs/plugin-vue';
|
|
5
|
-
import { defineConfig as defineConfig$1, mergeRsbuildConfig } from '@rsbuild/core';
|
|
6
|
-
import { pluginVue } from '@rsbuild/plugin-vue';
|
|
7
|
-
|
|
8
|
-
const GLOBALS = {
|
|
9
|
-
vue: "Vue",
|
|
10
|
-
"vue-router": "VueRouter",
|
|
11
|
-
"@vueuse/core": "VueUse",
|
|
12
|
-
"@vueuse/components": "VueUse",
|
|
13
|
-
"@vueuse/router": "VueUse",
|
|
14
|
-
"@halo-dev/console-shared": "HaloConsoleShared",
|
|
15
|
-
"@halo-dev/components": "HaloComponents",
|
|
16
|
-
"@halo-dev/api-client": "HaloApiClient",
|
|
17
|
-
"@halo-dev/richtext-editor": "RichTextEditor",
|
|
18
|
-
axios: "axios"
|
|
19
|
-
};
|
|
20
|
-
const EXTERNALS = Object.keys(GLOBALS);
|
|
21
|
-
|
|
22
|
-
const DEFAULT_MANIFEST_PATH = "../src/main/resources/plugin.yaml";
|
|
23
|
-
|
|
24
|
-
const DEFAULT_OUT_DIR_DEV = "../build/resources/main/console";
|
|
25
|
-
const DEFAULT_OUT_DIR_PROD = "./build/dist";
|
|
26
|
-
|
|
27
|
-
function getHaloPluginManifest(manifestPath) {
|
|
28
|
-
const manifest = yaml.load(
|
|
29
|
-
fs.readFileSync(manifestPath, "utf8")
|
|
30
|
-
);
|
|
31
|
-
return manifest;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const LEGACY_OUT_DIR_PROD = "../src/main/resources/console";
|
|
35
|
-
function HaloUIPluginBundlerKit(options = {}) {
|
|
36
|
-
return {
|
|
37
|
-
name: "halo-ui-plugin-bundler-kit",
|
|
38
|
-
config(config, env) {
|
|
39
|
-
const isProduction = env.mode === "production";
|
|
40
|
-
let outDir = isProduction ? LEGACY_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
41
|
-
if (options.outDir) {
|
|
42
|
-
if (typeof options.outDir === "string") {
|
|
43
|
-
outDir = options.outDir;
|
|
44
|
-
} else {
|
|
45
|
-
outDir = isProduction ? options.outDir.prod : options.outDir.dev;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const manifestPath = options.manifestPath || DEFAULT_MANIFEST_PATH;
|
|
49
|
-
const manifest = getHaloPluginManifest(manifestPath);
|
|
50
|
-
return {
|
|
51
|
-
...config,
|
|
52
|
-
define: {
|
|
53
|
-
"process.env": process.env
|
|
54
|
-
},
|
|
55
|
-
build: {
|
|
56
|
-
outDir,
|
|
57
|
-
emptyOutDir: true,
|
|
58
|
-
lib: {
|
|
59
|
-
entry: "src/index.ts",
|
|
60
|
-
name: manifest.metadata.name,
|
|
61
|
-
formats: ["iife"],
|
|
62
|
-
fileName: () => "main.js"
|
|
63
|
-
},
|
|
64
|
-
rollupOptions: {
|
|
65
|
-
external: EXTERNALS,
|
|
66
|
-
output: {
|
|
67
|
-
globals: GLOBALS,
|
|
68
|
-
extend: true
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function createVitePresetsConfig(manifestPath) {
|
|
78
|
-
const manifest = getHaloPluginManifest(manifestPath);
|
|
79
|
-
return defineConfig(({ mode }) => {
|
|
80
|
-
const isProduction = mode === "production";
|
|
81
|
-
return {
|
|
82
|
-
mode: mode || "production",
|
|
83
|
-
plugins: [Vue()],
|
|
84
|
-
define: {
|
|
85
|
-
"process.env": process.env
|
|
86
|
-
},
|
|
87
|
-
build: {
|
|
88
|
-
outDir: isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV,
|
|
89
|
-
emptyOutDir: true,
|
|
90
|
-
lib: {
|
|
91
|
-
entry: "src/index.ts",
|
|
92
|
-
name: manifest.metadata.name,
|
|
93
|
-
formats: ["iife"],
|
|
94
|
-
fileName: () => "main.js"
|
|
95
|
-
},
|
|
96
|
-
rollupOptions: {
|
|
97
|
-
external: EXTERNALS,
|
|
98
|
-
output: {
|
|
99
|
-
globals: GLOBALS,
|
|
100
|
-
extend: true
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function viteConfig(config) {
|
|
108
|
-
const presetsConfigFn = createVitePresetsConfig(
|
|
109
|
-
config?.manifestPath || DEFAULT_MANIFEST_PATH
|
|
110
|
-
);
|
|
111
|
-
return defineConfig((env) => {
|
|
112
|
-
const presetsConfig = presetsConfigFn(env);
|
|
113
|
-
const userConfig = typeof config?.vite === "function" ? config.vite(env) : config?.vite || {};
|
|
114
|
-
return mergeConfig(presetsConfig, userConfig);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function createRsbuildPresetsConfig(manifestPath) {
|
|
119
|
-
const manifest = getHaloPluginManifest(manifestPath);
|
|
120
|
-
return defineConfig$1(({ envMode }) => {
|
|
121
|
-
const isProduction = envMode === "production";
|
|
122
|
-
const outDir = isProduction ? DEFAULT_OUT_DIR_PROD : DEFAULT_OUT_DIR_DEV;
|
|
123
|
-
return {
|
|
124
|
-
mode: envMode || "production",
|
|
125
|
-
plugins: [pluginVue()],
|
|
126
|
-
source: {
|
|
127
|
-
entry: {
|
|
128
|
-
main: "./src/index.ts"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
dev: {
|
|
132
|
-
hmr: false
|
|
133
|
-
},
|
|
134
|
-
performance: {
|
|
135
|
-
chunkSplit: {
|
|
136
|
-
strategy: "custom"
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
tools: {
|
|
140
|
-
rspack: {
|
|
141
|
-
optimization: {
|
|
142
|
-
splitChunks: {
|
|
143
|
-
chunks: "async"
|
|
144
|
-
},
|
|
145
|
-
moduleIds: "named"
|
|
146
|
-
},
|
|
147
|
-
experiments: {
|
|
148
|
-
rspackFuture: {
|
|
149
|
-
bundlerInfo: {
|
|
150
|
-
force: false
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
module: {
|
|
155
|
-
parser: {
|
|
156
|
-
javascript: {
|
|
157
|
-
importMeta: false
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
output: {
|
|
162
|
-
publicPath: `/plugins/${manifest.metadata.name}/assets/console/`,
|
|
163
|
-
library: {
|
|
164
|
-
type: "window",
|
|
165
|
-
export: "default",
|
|
166
|
-
name: manifest.metadata.name
|
|
167
|
-
},
|
|
168
|
-
globalObject: "window",
|
|
169
|
-
iife: true
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
htmlPlugin: false
|
|
173
|
-
},
|
|
174
|
-
output: {
|
|
175
|
-
distPath: {
|
|
176
|
-
root: outDir,
|
|
177
|
-
js: "",
|
|
178
|
-
css: "",
|
|
179
|
-
jsAsync: "chunks",
|
|
180
|
-
cssAsync: "chunks"
|
|
181
|
-
},
|
|
182
|
-
cleanDistPath: true,
|
|
183
|
-
filename: {
|
|
184
|
-
css: (pathData) => {
|
|
185
|
-
if (pathData.chunk?.name === "main") {
|
|
186
|
-
return "style.css";
|
|
187
|
-
}
|
|
188
|
-
return "[name].[contenthash:8].css";
|
|
189
|
-
},
|
|
190
|
-
js: (pathData) => {
|
|
191
|
-
if (pathData.chunk?.name === "main") {
|
|
192
|
-
return "main.js";
|
|
193
|
-
}
|
|
194
|
-
return "[name].[contenthash:8].js";
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
externals: GLOBALS
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
function rsbuildConfig(config) {
|
|
203
|
-
const presetsConfigFn = createRsbuildPresetsConfig(
|
|
204
|
-
config?.manifestPath || DEFAULT_MANIFEST_PATH
|
|
205
|
-
);
|
|
206
|
-
return defineConfig$1((env) => {
|
|
207
|
-
const presetsConfig = presetsConfigFn(env);
|
|
208
|
-
const userConfig = typeof config?.rsbuild === "function" ? config.rsbuild(env) : config?.rsbuild || {};
|
|
209
|
-
return mergeRsbuildConfig(presetsConfig, userConfig);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export { HaloUIPluginBundlerKit, rsbuildConfig, viteConfig };
|