Skip to content

Commit 1549fda

Browse files
ref: account for output path diff between webpack versions
Co-authored-by: Abhijeet Prasad <[email protected]>
1 parent c93bab7 commit 1549fda

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/nextjs/src/utils/config.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as path from 'path';
77

88
const SENTRY_CLIENT_CONFIG_FILE = './sentry.client.config.js';
99
const SENTRY_SERVER_CONFIG_FILE = './sentry.server.config.js';
10-
// this is where the transpiled/bundled version of `USER_SERVER_CONFIG_FILE` will end up
10+
// this is where the transpiled/bundled version of `SENTRY_SERVER_CONFIG_FILE` will end up
1111
export const SERVER_SDK_INIT_PATH = 'sentry/initServerSDK.js';
1212

1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -21,7 +21,7 @@ type WebpackConfig = {
2121
devtool: string;
2222
plugins: PlainObject[];
2323
entry: EntryProperty;
24-
output: { path: string };
24+
output: { filename: string; path: string };
2525
target: string;
2626
context: string;
2727
};
@@ -156,7 +156,8 @@ export function withSentryConfig(
156156
// if we're building server code, store the webpack output path as an env variable, so we know where to look for the
157157
// webpack-processed version of `sentry.server.config.js` when we need it
158158
if (config.target === 'node') {
159-
const serverSDKInitOutputPath = path.join(config.output.path, SERVER_SDK_INIT_PATH);
159+
const outputLocation = path.dirname(path.join(config.output.path, config.output.filename));
160+
const serverSDKInitOutputPath = path.join(outputLocation, SERVER_SDK_INIT_PATH);
160161
const projectDir = config.context;
161162
setRuntimeEnvVars(projectDir, {
162163
// ex: .next/server/sentry/initServerSdk.js

0 commit comments

Comments
 (0)