-
-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
569a1c6
commit 00abc36
Showing
7 changed files
with
163 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// @ts-nocheck | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { createApp } from 'vinxi' | ||
import reactRefresh from '@vitejs/plugin-react' | ||
import tsconfigPaths from 'vite-tsconfig-paths' | ||
import { resolve } from 'import-meta-resolve' | ||
import { normalize } from 'vinxi/lib/path' | ||
import { TanStackRouterVite } from '@tanstack/router-vite-plugin' | ||
import { serverFunctions } from '@vinxi/server-functions/plugin' | ||
import { serverTransform } from '@vinxi/server-functions/server' | ||
import { config } from 'vinxi/plugins/config' | ||
// import type * as vite from 'vite' | ||
// import { config } from 'vinxi/plugins/config' | ||
|
||
function startVite() { | ||
return config('start-vite', {}) | ||
} | ||
|
||
export function defineConfig(opts) { | ||
return createApp({ | ||
server: { | ||
preset: 'vercel', | ||
experimental: { | ||
asyncStorage: true, | ||
asyncContext: true, | ||
}, | ||
}, | ||
routers: [ | ||
{ | ||
name: 'public', | ||
type: 'static', | ||
dir: './public', | ||
base: '/', | ||
}, | ||
{ | ||
name: 'ssr', | ||
type: 'http', | ||
handler: './app/server.tsx', | ||
target: 'server', | ||
plugins: () => [ | ||
startVite(), | ||
opts.vite?.(), | ||
TanStackRouterVite({ | ||
experimental: { | ||
enableCodeSplitting: false, | ||
}, | ||
}), | ||
tsconfigPaths(), | ||
serverTransform({ | ||
runtime: resolveRelativePath('../server/server-runtime.tsx'), | ||
}), | ||
], | ||
link: { | ||
client: 'client', | ||
}, | ||
}, | ||
{ | ||
name: 'client', | ||
type: 'client', | ||
handler: './app/client.tsx', | ||
target: 'browser', | ||
base: '/_build', | ||
build: { | ||
sourcemap: true, | ||
}, | ||
plugins: () => [ | ||
TanStackRouterVite({ | ||
experimental: { | ||
enableCodeSplitting: false, | ||
}, | ||
}), | ||
startVite(), | ||
opts.vite?.(), | ||
tsconfigPaths(), | ||
serverFunctions.client({ | ||
runtime: resolveRelativePath('../client/client-runtime.tsx'), | ||
}), | ||
reactRefresh(), | ||
], | ||
}, | ||
serverFunctions.router({ | ||
name: 'server', | ||
plugins: () => [startVite(), opts.vite?.(), tsconfigPaths()], | ||
handler: resolveRelativePath('../server/server-handler.tsx'), | ||
runtime: resolveRelativePath('../server/server-runtime.tsx'), | ||
}), | ||
], | ||
}) | ||
} | ||
|
||
function resolveRelativePath(p) { | ||
return path.relative( | ||
process.cwd(), | ||
resolve(p, import.meta.url) | ||
.split('://') | ||
.at(-1), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters