Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

vite.config.ts

71 lines2.2 KB

1import { defineConfig, mergeConfig } from 'vitest/config'
2import { tanstackViteConfig } from '@tanstack/vite-config'
3import packageJson from './package.json'
4import { fileURLToPath } from 'node:url'
5// this needs to be imported from the actual file instead of from 'index.tsx'
6// so we don't trigger the import of a `?script-string` import before the minifyScriptPlugin is setup
7import { VIRTUAL_MODULES } from './src/virtual-modules'
8​
9const config = defineConfig({
10 test: {
11 include: ['**/*.{test-d,test,spec}.?(c|m)[jt]s?(x)'],
12 name: packageJson.name,
13 watch: false,
14 environment: 'jsdom',
15 },
16})
17​
18const fakeStartEntry = fileURLToPath(
19 new URL('../start-client-core/src/fake-entries/start.ts', import.meta.url),
21const fakeRouterEntry = fileURLToPath(
22 new URL('../start-client-core/src/fake-entries/router.ts', import.meta.url),
24const fakeStartManifest = fileURLToPath(
25 new URL('./tests/fixtures/start-manifest.ts', import.meta.url),
27const fakePluginAdapters = fileURLToPath(
28 new URL('./src/empty-plugin-adapters.ts', import.meta.url),
30const fakeServerFnResolver = fileURLToPath(
31 new URL('./src/fake-start-server-fn-resolver.ts', import.meta.url),
33​
34export default mergeConfig(
35 config,
36 mergeConfig(
37 tanstackViteConfig({
38 tsconfigPath: './tsconfig.build.json',
39 srcDir: './src',
40 entry: [
41 './src/index.tsx',
42 './src/createServerRpc.ts',
43 './src/createSsrRpc.ts',
44 './src/request-response.ts',
45 './src/constants.ts',
46 './src/virtual-modules.ts',
47 './src/fake-start-server-fn-resolver.ts',
48 './src/empty-plugin-adapters.ts',
49 ],
50 externalDeps: [
51 ...Object.values(VIRTUAL_MODULES),
52 '#tanstack-start-entry',
53 '#tanstack-router-entry',
54 '#tanstack-start-server-fn-resolver',
55 '#tanstack-start-plugin-adapters',
56 ],
57 cjs: false,
58 }),
59 defineConfig({
60 resolve: {
61 alias: {
62 '#tanstack-start-entry': fakeStartEntry,
63 '#tanstack-router-entry': fakeRouterEntry,
64 '#tanstack-start-plugin-adapters': fakePluginAdapters,
65 '#tanstack-start-server-fn-resolver': fakeServerFnResolver,
66 'tanstack-start-manifest:v': fakeStartManifest,
67 },
68 },
69 }),
70 ),