From 9e0d24d6cc9ddd0b34eac3ff21074a5c968f6b8f Mon Sep 17 00:00:00 2001 From: Montia37 Date: Sun, 7 Sep 2025 22:53:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=20vite=20=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E7=A4=BA=E4=BE=8B=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 39357ae..b341aa3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,5 @@ import path from "path"; +import fs from "fs"; import tailwindcss from "@tailwindcss/vite"; import react from "@vitejs/plugin-react"; import { defineConfig, loadEnv } from "vite"; @@ -8,7 +9,22 @@ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()); return { - plugins: [react(), tailwindcss()], + plugins: [ + react(), + tailwindcss(), + { + name: "exclude-examples", + apply: "build", + writeBundle(options) { + if (options.dir) { + const examplesDir = path.resolve(options.dir, "examples"); + if (fs.existsSync(examplesDir)) { + fs.rmSync(examplesDir, { recursive: true, force: true }); + } + } + }, + }, + ], resolve: { alias: { "@": path.resolve(__dirname, "./src"),