Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/cloudflare-workers-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Cloudflare Workers Builds is the production deployment owner. Its production tri

The CI deploy command applies every committed migration and verifies the exact Builder schema before `wrangler deploy` can run. Preview builds use `wrangler versions upload` and must not receive the production database secret.

Set `SENTRY_AUTH_TOKEN` under **Settings → Build → Build variables and secrets** for the `tanstack-com` Worker. Builds on `main` use this token to upload browser and Worker source maps to `tanstack/tanstack-com`. Check the build log and the [Sentry Source Maps page](https://tanstack.sentry.io/settings/projects/tanstack-com/source-maps/) after the next production build.

Required environment:

- `DATABASE_URL`: the production Postgres connection used to verify the Builder schema before the Worker is deployed. Run `pnpm run db:prepare-builder` once after a Builder schema change.
Expand Down
1 change: 1 addition & 0 deletions public/.assetsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.map
39 changes: 24 additions & 15 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ import { workerIsolation } from './scripts/worker-isolation-vite'
const isDev = process.env.NODE_ENV !== 'production'
const shouldUseRedact = process.env.DISABLE_REDACT !== 'true'
const localRedactPackageRoot = process.env.LOCAL_REDACT_PACKAGE_ROOT
const shouldUseSentryPlugin =
process.env.NODE_ENV === 'production' &&
Boolean(process.env.SENTRY_AUTH_TOKEN)
const shouldBuildSourcemaps =
shouldUseSentryPlugin || process.env.BUILD_SOURCEMAPS === 'true'
const SITE_URL = process.env.STAGING_SITE_URL || 'https://tanstack.com'
const localDocsDevToken = isDev ? randomUUID() : ''

Expand Down Expand Up @@ -217,6 +212,19 @@ function chatBuildId() {

export default defineConfig(async ({ command, mode }) => {
const localEnv = { ...loadEnv(mode, __dirname, ''), ...process.env }
const isProductionBuild = command === 'build' && mode === 'production'
const cloudflareBranch = process.env.WORKERS_CI_BRANCH
const sentryAuthToken =
isProductionBuild && (!cloudflareBranch || cloudflareBranch === 'main')
? localEnv.SENTRY_AUTH_TOKEN
: undefined
const shouldBuildSourcemaps =
Boolean(sentryAuthToken) || localEnv.BUILD_SOURCEMAPS === 'true'
if (isProductionBuild && cloudflareBranch === 'main' && !sentryAuthToken) {
console.warn(
'[Sentry] Source map upload skipped. Set SENTRY_AUTH_TOKEN in Cloudflare Workers Builds.',
)
}
const useRemoteAi = Boolean(localEnv.CLOUDFLARE_API_TOKEN)
const egress = command === 'serve' ? await startLocalMcpEgress() : undefined
const config: UserConfig = {
Expand Down Expand Up @@ -264,6 +272,9 @@ export default defineConfig(async ({ command, mode }) => {
: undefined,
},
environments: {
client: {
build: { sourcemap: shouldBuildSourcemaps ? 'hidden' : false },
},
ssr: {
optimizeDeps: {
// Resolve SSR dependencies through Redact instead of a separate prebundle.
Expand Down Expand Up @@ -520,16 +531,6 @@ export default defineConfig(async ({ command, mode }) => {
viteReact(),
chatIsolation(),
workerIsolation(),

...(shouldUseSentryPlugin
? [
sentryTanstackStart({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'tanstack',
project: 'tanstack-com',
}),
]
: []),
contentCollections(),
tailwindcss(),
...(process.env.ANALYZE
Expand All @@ -541,6 +542,14 @@ export default defineConfig(async ({ command, mode }) => {
}),
]
: []),
...(sentryAuthToken
? sentryTanstackStart({
authToken: sentryAuthToken,
org: 'tanstack',
project: 'tanstack-com',
autoInstrumentMiddleware: false,
})
: []),
],
}
return config
Expand Down
Loading