Skip to content

Commit

Permalink
chore: simplify bundler config (#78)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Wang <[email protected]>
  • Loading branch information
ruibaby authored Feb 18, 2024
1 parent a5ab1cc commit bc2c9ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 56 deletions.
1 change: 1 addition & 0 deletions console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 12 additions & 56 deletions console/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
});
};
},
});

0 comments on commit bc2c9ec

Please sign in to comment.