Skip to content

Commit

Permalink
fix(start): pass through vite react plugin config options (#2955)
Browse files Browse the repository at this point in the history
fixes #2952
  • Loading branch information
schiller-manuel authored Dec 8, 2024
1 parent 402bae6 commit 58fd908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
8 changes: 2 additions & 6 deletions packages/start/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'node:path'
import { existsSync, readFileSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import reactRefresh from '@vitejs/plugin-react'
import viteReact from '@vitejs/plugin-react'
import { resolve } from 'import-meta-resolve'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import {
Expand Down Expand Up @@ -173,11 +173,7 @@ export function defineConfig(
serverFunctions.client({
runtime: '@tanstack/start/client-runtime',
}),
reactRefresh({
babel: opts.react?.babel,
exclude: opts.react?.exclude,
include: opts.react?.include,
}),
viteReact(opts.react),
// TODO: RSCS - enable this
// serverComponents.client(),
]
Expand Down
16 changes: 3 additions & 13 deletions packages/start/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod'
import type { PluginOption } from 'vite'
import type { AppOptions as VinxiAppOptions } from 'vinxi'
import type { NitroOptions } from 'nitropack'

import type { Options as ViteReactOptions } from '@vitejs/plugin-react'
import type { CustomizableConfig } from 'vinxi/dist/types/lib/vite-dev'

type StartUserViteConfig = CustomizableConfig | (() => CustomizableConfig)
Expand Down Expand Up @@ -138,17 +138,7 @@ export const serverSchema = z

const viteSchema = z.custom<StartUserViteConfig>()

const babelSchema = z.object({
plugins: z
.array(z.union([z.tuple([z.string(), z.any()]), z.string()]))
.optional(),
})

const reactSchema = z.object({
babel: babelSchema.optional(),
exclude: z.array(z.instanceof(RegExp)).optional(),
include: z.array(z.instanceof(RegExp)).optional(),
})
const viteReactSchema = z.custom<ViteReactOptions>()

const routersSchema = z.object({
ssr: z
Expand Down Expand Up @@ -192,7 +182,7 @@ const tsrConfig = configSchema.partial().extend({
})

export const inlineConfigSchema = z.object({
react: reactSchema.optional(),
react: viteReactSchema.optional(),
vite: viteSchema.optional(),
tsr: tsrConfig.optional(),
routers: routersSchema.optional(),
Expand Down

0 comments on commit 58fd908

Please sign in to comment.