| 10 | import type { PluginOption } from 'vite' |
| 11 | |
| 12 | export function tanstackStart( |
| 13 | options?: TanStackStartViteInputConfig, |
| 14 | ): Array<PluginOption> { |
| 15 | const corePluginOpts: TanStackStartVitePluginCoreOptions = { |
| 16 | framework: 'solid', |
| 17 | defaultEntryPaths: solidStartDefaultEntryPaths, |
| 18 | providerEnvironmentName: START_ENVIRONMENT_NAMES.server, |
| 19 | ssrIsProvider: true, |
| 20 | ssrResolverStrategy: { |
| 21 | type: 'default', |
| 22 | }, |
| 23 | } |
| 24 | |
| 25 | return [ |
| 26 | { |
| 27 | name: 'tanstack-solid-start:config', |
| 28 | config() { |
| 29 | return { |
| 30 | ssr: { |
| 31 | noExternal: [ |
| 32 | '@tanstack/solid-router-ssr-query', |
| 33 | '@tanstack/solid-query', |
| 34 | '@tanstack/solid-query-devtools', |
| 35 | ], |
| 36 | }, |
| 37 | } |
| 38 | }, |
| 39 | configEnvironment(environmentName, options) { |
| 40 | return { |
| 41 | optimizeDeps: |
| 42 | environmentName === START_ENVIRONMENT_NAMES.client || |
| 43 | (environmentName === START_ENVIRONMENT_NAMES.server && |
| 44 | // This indicates that the server environment has opted in to dependency optimization |
| 45 | options.optimizeDeps?.noDiscovery === false) |
| 46 | ? { |
| 47 | // As `@tanstack/solid-start` depends on `@tanstack/solid-router`, we should exclude both. |
| 48 | exclude: [ |
| 49 | '@tanstack/solid-start', |
| 50 | '@tanstack/solid-router', |
| 51 | '@tanstack/start-static-server-functions', |
| 52 | ], |
| 53 | } |
| 54 | : undefined, |
| 55 | } |
| 56 | }, |
| 57 | }, |
| 58 | tanStackStartVite(corePluginOpts, options), |
| 59 | ] |
| 60 | } |