From bc2c9ecb3bb2fadaba50b7c1639a24e20dd35d23 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 18 Feb 2024 10:19:07 +0800 Subject: [PATCH] chore: simplify bundler config (#78) Signed-off-by: Ryan Wang --- console/package.json | 1 + console/pnpm-lock.yaml | 12 ++++++++ console/vite.config.ts | 68 ++++++++---------------------------------- 3 files changed, 25 insertions(+), 56 deletions(-) diff --git a/console/package.json b/console/package.json index a5d464f..bb1d26d 100644 --- a/console/package.json +++ b/console/package.json @@ -30,6 +30,7 @@ "vue-router": "^4.1.6" }, "devDependencies": { + "@halo-dev/ui-plugin-bundler-kit": "^2.12.0", "@iconify/json": "^2.2.31", "@rushstack/eslint-patch": "^1.2.0", "@tailwindcss/aspect-ratio": "^0.4.2", diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml index f95a66d..87a7d84 100644 --- a/console/pnpm-lock.yaml +++ b/console/pnpm-lock.yaml @@ -67,6 +67,9 @@ dependencies: version: 4.1.6(vue@3.2.47) devDependencies: + '@halo-dev/ui-plugin-bundler-kit': + specifier: ^2.12.0 + version: 2.12.0(vite@4.5.0) '@iconify/json': specifier: ^2.2.31 version: 2.2.31 @@ -537,6 +540,15 @@ packages: - '@nuxt/kit' dev: false + /@halo-dev/ui-plugin-bundler-kit@2.12.0(vite@4.5.0): + resolution: {integrity: sha512-3558qzH5RN9pB2j0ZonuIxX3cw8lh870cWpPPHjkDxTIjKt+aO5tjKhcqKlFL853jdx9nHIIS+nMDCeqjejpxw==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + vite: ^4.0.0 || ^5.0.0 + dependencies: + vite: 4.5.0(@types/node@16.18.14)(sass@1.69.5) + dev: true + /@humanwhocodes/config-array@0.11.8: resolution: {integrity: sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==} engines: {node: '>=10.10.0'} diff --git a/console/vite.config.ts b/console/vite.config.ts index 2a0d3e0..17a65a1 100644 --- a/console/vite.config.ts +++ b/console/vite.config.ts @@ -3,61 +3,17 @@ import { fileURLToPath, URL } from "url"; import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import Icons from "unplugin-icons/vite"; +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(), Icons({ compiler: "vue3" })], - resolve: { - alias: { - "@": fileURLToPath(new URL("./src", import.meta.url)), - // To resolve conflict between @tiptap and @halo-dev/richtext-editor - "@tiptap/pm/state": "@halo-dev/richtext-editor", - "@tiptap/core": "@halo-dev/richtext-editor", - "@tiptap/pm/view": "@halo-dev/richtext-editor", - }, - }, - define: { - "process.env": process.env, - }, - build: { - outDir, - emptyOutDir: true, - lib: { - entry: "src/index.ts", - name: "PluginMoments", - formats: ["iife"], - fileName: () => "main.js", - }, - rollupOptions: { - external: [ - "vue", - "vue-router", - "@vueuse/core", - "@vueuse/components", - "@vueuse/router", - "@halo-dev/shared", - "@halo-dev/components", - "@halo-dev/richtext-editor", - ], - 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", - "@halo-dev/richtext-editor": "RichTextEditor", - }, - }, - }, +export default defineConfig({ + plugins: [vue(), Icons({ compiler: "vue3" }), HaloUIPluginBundlerKit()], + resolve: { + alias: { + "@": fileURLToPath(new URL("./src", import.meta.url)), + // To resolve conflict between @tiptap and @halo-dev/richtext-editor + "@tiptap/pm/state": "@halo-dev/richtext-editor", + "@tiptap/core": "@halo-dev/richtext-editor", + "@tiptap/pm/view": "@halo-dev/richtext-editor", }, - }); -}; + }, +});