From 7eb954624108ac56e1a7a4be1434995f4dc518f6 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 5 Feb 2024 11:23:11 +0800 Subject: [PATCH] chore: simplify bundler config Signed-off-by: Ryan Wang --- console/package.json | 1 + console/pnpm-lock.yaml | 12 ++++++++ console/vite.config.ts | 65 +++++++++--------------------------------- 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/console/package.json b/console/package.json index 168c8d2..97565af 100644 --- a/console/package.json +++ b/console/package.json @@ -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", diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml index f21c997..acfaa9c 100644 --- a/console/pnpm-lock.yaml +++ b/console/pnpm-lock.yaml @@ -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'} diff --git a/console/vite.config.ts b/console/vite.config.ts index 279ab4f..9211d6a 100644 --- a/console/vite.config.ts +++ b/console/vite.config.ts @@ -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, - }, - }, - }, - }); -}; + }, +});