chore: simplify bundler config

Signed-off-by: Ryan Wang <i@ryanc.cc>
This commit is contained in:
Ryan Wang 2024-02-05 11:23:11 +08:00
parent 23cdb944a6
commit 7eb9546241
3 changed files with 26 additions and 52 deletions

View File

@ -20,6 +20,7 @@
"vue": "^3.3.4"
},
"devDependencies": {
"@halo-dev/ui-plugin-bundler-kit": "^2.12.0",
"@iconify/json": "^2.2.76",
"@rushstack/eslint-patch": "^1.3.1",
"@types/canvas-confetti": "^1.6.0",

View File

@ -28,6 +28,9 @@ dependencies:
version: 3.3.12(typescript@4.7.4)
devDependencies:
'@halo-dev/ui-plugin-bundler-kit':
specifier: ^2.12.0
version: 2.12.0(vite@3.2.7)
'@iconify/json':
specifier: ^2.2.76
version: 2.2.159
@ -595,6 +598,15 @@ packages:
vue-router: 4.2.5(vue@3.3.12)
dev: false
/@halo-dev/ui-plugin-bundler-kit@2.12.0(vite@3.2.7):
resolution: {integrity: sha512-3558qzH5RN9pB2j0ZonuIxX3cw8lh870cWpPPHjkDxTIjKt+aO5tjKhcqKlFL853jdx9nHIIS+nMDCeqjejpxw==}
engines: {node: ^18.0.0 || >=20.0.0}
peerDependencies:
vite: ^4.0.0 || ^5.0.0
dependencies:
vite: 3.2.7(@types/node@16.18.68)(sass@1.69.5)
dev: true
/@humanwhocodes/config-array@0.11.13:
resolution: {integrity: sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==}
engines: {node: '>=10.10.0'}

View File

@ -4,58 +4,19 @@ import { defineConfig } from "vite";
import Vue from "@vitejs/plugin-vue";
import VueJsx from "@vitejs/plugin-vue-jsx";
import Icons from "unplugin-icons/vite";
const pluginEntryName = "vditor-mde";
import { HaloUIPluginBundlerKit } from "@halo-dev/ui-plugin-bundler-kit";
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
const isProduction = mode === "production";
const outDir = isProduction
? "../src/main/resources/console"
: "../build/resources/main/console";
return defineConfig({
plugins: [Vue(),VueJsx(), Icons({ compiler: "vue3" })],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
export default defineConfig({
plugins: [
Vue(),
VueJsx(),
Icons({ compiler: "vue3" }),
HaloUIPluginBundlerKit(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
define: {
"process.env": process.env,
},
build: {
outDir,
emptyOutDir: true,
lib: {
entry: "src/index.ts",
name: pluginEntryName,
formats: ["iife"],
fileName: () => "main.js",
},
rollupOptions: {
external: [
"vue",
"vue-router",
"@vueuse/core",
"@vueuse/components",
"@vueuse/router",
"@halo-dev/shared",
"@halo-dev/components",
],
output: {
globals: {
vue: "Vue",
"vue-router": "VueRouter",
"@vueuse/core": "VueUse",
"@vueuse/components": "VueUse",
"@vueuse/router": "VueUse",
"@halo-dev/console-shared": "HaloConsoleShared",
"@halo-dev/components": "HaloComponents",
},
extend: true,
},
},
},
});
};
},
});