Skip to content

Commit ecce964

Browse files
committed
fix: output files to correct directory
1 parent 85cbaf8 commit ecce964

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/client-build.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import path from 'path'
21
import type { Plugin, UserConfig } from 'vite'
32

43
export interface ClientBuildOptions {
5-
outDir?: string
4+
outDir?: string // Client output directory
5+
emptyOutDir?: boolean // Whether to empty the output directory before build
66
}
77

8-
export const defaultClientBuildOptions: Required<ClientBuildOptions> = {
9-
outDir: 'dist',
8+
export const defaultClientBuildOptions: Partial<ClientBuildOptions> = {
9+
outDir: 'public',
10+
emptyOutDir: true,
1011
}
1112

1213
export function clientBuild(options?: ClientBuildOptions): Plugin {
@@ -21,12 +22,10 @@ export function clientBuild(options?: ClientBuildOptions): Plugin {
2122
},
2223

2324
config(): UserConfig {
24-
// Output to 'dist/public' (or custom outDir/public)
25-
const clientOutDir = path.join(mergedOptions.outDir, 'public')
26-
2725
return {
2826
build: {
29-
outDir: clientOutDir,
27+
outDir: mergedOptions.outDir,
28+
emptyOutDir: mergedOptions.emptyOutDir,
3029
},
3130
}
3231
},

src/srvx.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export interface SrvxOptions extends DevServerOptions {
88
outDir?: string;
99
serverOutFile?: string;
1010
framework?: "vercel"; // Target framework for deployment
11+
// Client build options
12+
clientOutDir?: string; // Client output directory (default: "public")
13+
clientEmptyOutDir?: boolean; // Whether to empty the client output directory before build (default: true)
1114
}
1215

1316
export const defaultSrvxOptions: Partial<SrvxOptions> = {
@@ -30,7 +33,8 @@ export function srvx(options?: SrvxOptions): Plugin[] {
3033

3134
// Client build plugin
3235
clientBuild({
33-
outDir: mergedOptions.outDir,
36+
outDir: mergedOptions.clientOutDir,
37+
emptyOutDir: mergedOptions.clientEmptyOutDir,
3438
}),
3539

3640
// Server build plugin

0 commit comments

Comments
 (0)