Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ink-victor committed Feb 5, 2025
1 parent b8013ae commit fc7e24f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Environment
NEXT_PUBLIC_ENVIRONMENT=

# Sentry
# Sentry (Optional)
NEXT_PUBLIC_SENTRY_DSN=
SENTRY_AUTH_TOKEN=

Expand Down
56 changes: 26 additions & 30 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,29 @@ const nextConfig: NextConfig = {
},
};

console.debug(`NEXT_PUBLIC_ENVIRONMENT: ${clientEnv.NEXT_PUBLIC_ENVIRONMENT}`);

export default clientEnv.NEXT_PUBLIC_ENVIRONMENT === "ci"
? nextConfig
: withSentryConfig(withNextIntl(nextConfig), {
// For all available options, see node_modules/@sentry/nextjs/build/types/config/types.d.ts

org: "payward-inc",
project: "ink-web-app",
authToken: env.SENTRY_AUTH_TOKEN,
silent: true,

// Sourcemaps config
sourcemaps: {
// Send source maps to Sentry, but do not include them in the client bundle
deleteSourcemapsAfterUpload: true,
},

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
});
export default withSentryConfig(withNextIntl(nextConfig), {
// For all available options, see node_modules/@sentry/nextjs/build/types/config/types.d.ts

org: "payward-inc",
project: "ink-web-app",
authToken: env.SENTRY_AUTH_TOKEN,
silent: true,

// Sourcemaps config
sourcemaps: {
// Send source maps to Sentry, but do not include them in the client bundle
deleteSourcemapsAfterUpload: true,
},

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
});
10 changes: 9 additions & 1 deletion scripts/generate-dummy-dotenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ while IFS= read -r line || [ -n "$line" ]; do
# Get the variable name (everything before =)
var_name=$(echo "$line" | cut -d= -f1)

# Skip variables that start with SENTRY_ variables as they mess up the build if defined with dummy data... Learned this the hard way:
# node_modules/@sentry/nextjs/build/types/config/types.d.ts
if [[ "$var_name" =~ ^SENTRY_ ]]; then
continue
fi

# Get existing environment variable value if it exists
existing_value="${!var_name}"

Expand All @@ -17,8 +23,10 @@ while IFS= read -r line || [ -n "$line" ]; do
echo "${var_name}=${existing_value}" >> .env.production
else
# No existing value, use dummy values based on variable name
if [[ "$var_name" == *_URL ]]; then
if [[ "$var_name" =~ _URL$ ]] || [[ "$var_name" =~ _DSN$ ]]; then
echo "${var_name}=https://dummy-url.com/" >> .env.production
elif [[ "$var_name" == "NEXT_PUBLIC_ENVIRONMENT" ]]; then
echo "${var_name}=ci" >> .env.production
else
echo "${var_name}=DUMMY_DO_NOT_REPLACE" >> .env.production
fi
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from "zod";
export const env = createEnv({
server: {
CI: z.string().optional(),
SENTRY_AUTH_TOKEN: z.string().min(1),
SENTRY_AUTH_TOKEN: z.string().optional(),
ORIGIN: z.string().min(1).default("inkonchain.com"),
BRAZE_INSTANCE_URL: z.string().url(),
BRAZE_API_KEY: z.string().min(1),
Expand Down

0 comments on commit fc7e24f

Please sign in to comment.