Skip to content

Commit 83ae1c9

Browse files
committed
Refactor deployment target types and add validation function
1 parent 526dd17 commit 83ae1c9

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/types/deployment.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Valid deployment targets for the application
3+
*/
4+
export type DeploymentTarget = 'netlify' | 'vercel' | 'cloudflare-pages' | 'node-server' | 'bun';
5+
6+
/**
7+
* Configuration options for TanStack Start plugin
8+
*/
9+
export interface TanStackStartOptions {
10+
target?: DeploymentTarget;
11+
}
12+
13+
/**
14+
* Validates if a string is a valid deployment target
15+
*/
16+
export function isValidDeploymentTarget(target: string): target is DeploymentTarget {
17+
const validTargets: DeploymentTarget[] = [
18+
'netlify',
19+
'vercel',
20+
'cloudflare-pages',
21+
'node-server',
22+
'bun',
23+
];
24+
return validTargets.includes(target as DeploymentTarget);
25+
}

vite.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import tailwindcss from '@tailwindcss/vite';
22
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
33
import { defineConfig, loadEnv } from 'vite';
44
import tsConfigPaths from 'vite-tsconfig-paths';
5-
6-
// Define valid deployment targets
7-
type DeploymentTarget = 'netlify' | 'vercel' | 'cloudflare-pages' | 'node-server' | 'bun';
5+
import type { DeploymentTarget, TanStackStartOptions } from '~/types/deployment';
86

97
export default defineConfig(({ mode }) => {
108
// Load environment variables
@@ -14,7 +12,7 @@ export default defineConfig(({ mode }) => {
1412
const deploymentTarget = env.VITE_DEPLOYMENT_TARGET as DeploymentTarget | undefined;
1513

1614
// Prepare tanstackStart options
17-
const tanstackStartOptions: { target?: DeploymentTarget } = {};
15+
const tanstackStartOptions: TanStackStartOptions = {};
1816
if (deploymentTarget) {
1917
tanstackStartOptions.target = deploymentTarget;
2018
}

0 commit comments

Comments
 (0)