Open History to see the last commit
1import { fileURLToPath } from 'node:url'
2import {
3 TanStackStartVitePluginCore,
4 VITE_ENVIRONMENT_NAMES,
5} from '@tanstack/start-plugin-core'
6import path from 'pathe'
7import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core'
8import type { PluginOption } from 'vite'
9β
10const currentDir = path.dirname(fileURLToPath(import.meta.url))
11const defaultEntryDir = path.resolve(
12 currentDir,
13 '..',
14 '..',
15 'plugin',
16 'default-entry',
17)
18const defaultEntryPaths = {
19 client: path.resolve(defaultEntryDir, 'client.tsx'),
20 server: path.resolve(defaultEntryDir, 'server.ts'),
21 start: path.resolve(defaultEntryDir, 'start.ts'),
22}
23β
24export function tanstackStart(
25 options?: TanStackStartInputConfig,
26): Array<PluginOption> {
27 return [
28 {
29 name: 'tanstack-solid-start:config',
30 configEnvironment(environmentName, options) {
31 return {
32 optimizeDeps:
33 environmentName === VITE_ENVIRONMENT_NAMES.client ||
34 (environmentName === VITE_ENVIRONMENT_NAMES.server &&
35 // This indicates that the server environment has opted in to dependency optimization
36 options.optimizeDeps?.noDiscovery === false)
37 ? {
38 // As `@tanstack/solid-start` depends on `@tanstack/solid-router`, we should exclude both.
39 exclude: [
40 '@tanstack/solid-start',
41 '@tanstack/solid-router',
42 '@tanstack/start-static-server-functions',
43 ],
44 }
45 : undefined,
46 }
47 },
48 },
49 TanStackStartVitePluginCore(
50 {
51 framework: 'solid',
52 defaultEntryPaths,
53 },
54 options,
55 ),
56 ]
57}