Skip to content

Commit bff204f

Browse files
committed
feat: sourcemaps
1 parent 2146bf6 commit bff204f

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

apps/frontend/next.config.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ const nextConfig = {
1010
transpilePackages: ['crypto-hash'],
1111
// Enable production sourcemaps for Sentry
1212
productionBrowserSourceMaps: true,
13+
14+
// Custom webpack config to ensure sourcemaps are generated properly
15+
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
16+
// Enable sourcemaps for both client and server in production
17+
if (!dev) {
18+
config.devtool = isServer ? 'source-map' : 'hidden-source-map';
19+
}
20+
21+
return config;
22+
},
23+
1324
images: {
1425
remotePatterns: [
1526
{
@@ -50,30 +61,48 @@ export default withSentryConfig(nextConfig, {
5061
project: process.env.SENTRY_PROJECT,
5162
authToken: process.env.SENTRY_AUTH_TOKEN,
5263

53-
// Sourcemap configuration
64+
// Sourcemap configuration optimized for monorepo
5465
sourcemaps: {
55-
disable: false, // Enable sourcemap upload (default: false)
56-
assets: ["**/*.js", "**/*.js.map"], // Files to upload
57-
ignore: ["**/node_modules/**"], // Exclude node_modules
58-
deleteSourcemapsAfterUpload: true, // Delete sourcemaps after upload for security
66+
disable: false,
67+
// More comprehensive asset patterns for monorepo
68+
assets: [
69+
".next/static/**/*.js",
70+
".next/static/**/*.js.map",
71+
".next/server/**/*.js",
72+
".next/server/**/*.js.map",
73+
],
74+
ignore: [
75+
"**/node_modules/**",
76+
"**/*hot-update*",
77+
"**/_buildManifest.js",
78+
"**/_ssgManifest.js",
79+
"**/*.test.js",
80+
"**/*.spec.js",
81+
],
82+
deleteSourcemapsAfterUpload: true,
5983
},
6084

61-
// Release configuration (optional but recommended)
85+
// Release configuration
6286
release: {
63-
create: true, // Create release in Sentry
64-
finalize: true, // Finalize release after build
87+
create: true,
88+
finalize: true,
89+
// Use git commit hash for releases in monorepo
90+
name: process.env.VERCEL_GIT_COMMIT_SHA || process.env.GITHUB_SHA || undefined,
6591
},
6692

93+
// NextJS specific optimizations for monorepo
94+
widenClientFileUpload: true,
95+
6796
// Additional configuration
6897
telemetry: false,
69-
silent: process.env.NODE_ENV === 'production', // Reduce build logs in production
70-
debug: process.env.NODE_ENV === 'development', // Enable debug in development
98+
silent: process.env.NODE_ENV === 'production',
99+
debug: process.env.NODE_ENV === 'development',
71100

72101
// Error handling for CI/CD
73102
errorHandler: (error) => {
74-
console.warn("Sentry build error occurred:", error);
75-
// Don't fail the build if Sentry upload fails
76-
// Remove the next line if you want builds to fail on Sentry errors
103+
console.warn("Sentry build error occurred:", error.message);
104+
console.warn("This might be due to missing Sentry environment variables or network issues");
105+
// Don't fail the build if Sentry upload fails in monorepo context
77106
return;
78107
},
79108
});

apps/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "dotenv -e ../../.env -- next dev -p 4200",
88
"build": "next build",
9+
"build:sentry": "dotenv -e ../../.env -- next build",
910
"start": "dotenv -e ../../.env -- next start -p 4200",
1011
"pm2": "pm2 start pnpm --name frontend -- start"
1112
},

0 commit comments

Comments
 (0)