From a2a73ce2ddc881e9b3328bc20343a74f8f227bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 14 Nov 2025 21:25:29 +0800 Subject: [PATCH] Add dev build script and improve Vite config Introduces a 'build:shell:dev' script for development builds and updates napcat-shell's Vite config to conditionally enable source maps in development mode. This enhances build flexibility for development and production environments. --- package.json | 1 + packages/napcat-shell/package.json | 1 + packages/napcat-shell/vite.config.ts | 12 +++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a2655f9f..70439c95 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "version": "0.0.1", "scripts": { "build:shell": "pnpm --filter napcat-shell run build || exit 1", + "build:shell:dev": "pnpm --filter napcat-shell run build:dev || exit 1", "build:framework": "pnpm --filter napcat-framework run build || exit 1", "build:webui": "pnpm --filter napcat-webui-frontend run build || exit 1", "dev:shell": "pnpm --filter napcat-develop run dev || exit 1", diff --git a/packages/napcat-shell/package.json b/packages/napcat-shell/package.json index 13ca4154..61bd712d 100644 --- a/packages/napcat-shell/package.json +++ b/packages/napcat-shell/package.json @@ -6,6 +6,7 @@ "main": "index.ts", "scripts": { "build": "vite build", + "build:dev": "vite build --mode development", "typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json" }, "exports": { diff --git a/packages/napcat-shell/vite.config.ts b/packages/napcat-shell/vite.config.ts index b956995d..72f801e1 100644 --- a/packages/napcat-shell/vite.config.ts +++ b/packages/napcat-shell/vite.config.ts @@ -34,7 +34,7 @@ const ShellBaseConfigPlugin: PluginOption[] = [ nodeResolve(), napcatVersion(), ]; -const ShellBaseConfig = () => +const ShellBaseConfig = (source_map: boolean = false) => defineConfig({ resolve: { conditions: ['node', 'default'], @@ -48,7 +48,7 @@ const ShellBaseConfig = () => }, }, build: { - sourcemap: true, + sourcemap: source_map, target: 'esnext', minify: false, lib: { @@ -65,7 +65,13 @@ const ShellBaseConfig = () => }, }, }); -export default defineConfig((): UserConfig => { +export default defineConfig(({ mode }): UserConfig => { + if (mode === 'development') { + return { + ...ShellBaseConfig(true), + plugins: [...ShellBaseConfigPlugin], + }; + } return { ...ShellBaseConfig(), plugins: [...ShellBaseConfigPlugin],