Skip to content

Commit 63b504a

Browse files
committed
add docs for build config
1 parent 73c80f5 commit 63b504a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/react-router/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,41 @@ Update the `start` and `dev` script to include the instrumentation file:
144144
"start": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js",
145145
}
146146
```
147+
148+
## Build-time Config
149+
150+
Update your vite.config.ts file to include the `sentryReactRouter` plugin and also add the your config options to the vite config (this is required for uploading sourcemaps at the end of the build):
151+
152+
```ts
153+
import { reactRouter } from '@react-router/dev/vite';
154+
import { sentryReactRouter } from '@sentry/react-router';
155+
import tailwindcss from '@tailwindcss/vite';
156+
import { defineConfig } from 'vite';
157+
import tsconfigPaths from 'vite-tsconfig-paths';
158+
159+
const sentryConfig = {
160+
authToken: '...',
161+
org: '...',
162+
project: '...',
163+
// rest of your config
164+
};
165+
166+
export default defineConfig(config => {
167+
return {
168+
plugins: [reactRouter(), sentryReactRouter(sentryConfig, config)],
169+
sentryConfig,
170+
};
171+
});
172+
```
173+
174+
Next, in your `react-router.config.ts` file, include the `sentryOnBuildEnd` hook:
175+
176+
```ts
177+
import type { Config } from '@react-router/dev/config';
178+
import { sentryOnBuildEnd } from '@sentry/react-router';
179+
180+
export default {
181+
ssr: true,
182+
buildEnd: sentryOnBuildEnd,
183+
} satisfies Config;
184+
```

0 commit comments

Comments
 (0)