@@ -89,28 +89,6 @@ export function constructWebpackConfigFunction(
89
89
} ;
90
90
}
91
91
92
- // Support non-default output directories by making the output path (easy to get here at build-time) available to
93
- // the SDK's default `RewriteFrames` instance (which needs it at runtime).
94
- // const distDir = buildContext.config.distDir;
95
- newConfig . plugins = newConfig . plugins || [ ] ;
96
-
97
- // const definePluginInstance = findWebpackPlugin(newConfig, 'DefinePlugin') as DefinePlugin;
98
- //
99
- // if (definePluginInstance) {
100
- // definePluginInstance.definitions['__rewriteFramesDistDir__'] = distDir;
101
- // } else {
102
- // newConfig.plugins.push(new DefinePlugin({ __rewriteFramesDistDir__: distDir }));
103
- // }
104
-
105
- // if (buildContext.isServer) {
106
- // newConfig.plugins.push(
107
- // (new InjectPlugin(() => `global.__rewriteFramesDistDir__ = ${distDir};`, {
108
- // entryName: shouldAddSentryToEntryPoint, // Limit the injected code to only the entry w/ this name
109
- // entryOrder: ENTRY_ORDER.First, // Make the injected code be the first entry point
110
- // }) as unknown) as WebpackPluginInstance, // necessary because of a mismatch in @types/webpack versions between this plugin
111
- // );
112
- // }
113
-
114
92
// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
115
93
const enableWebpackPlugin = buildContext . isServer
116
94
? ! userNextConfig . sentry ?. disableServerWebpackPlugin
@@ -127,6 +105,7 @@ export function constructWebpackConfigFunction(
127
105
newConfig . devtool = 'source-map' ;
128
106
}
129
107
108
+ newConfig . plugins = newConfig . plugins || [ ] ;
130
109
newConfig . plugins . push (
131
110
new SentryWebpackPlugin ( getWebpackPluginOptions ( buildContext , userSentryWebpackPluginOptions ) ) ,
132
111
) ;
@@ -168,30 +147,24 @@ async function addSentryToEntryProperty(
168
147
// we need to turn the filename into a path so webpack can find it
169
148
const filesToInject = [ `./${ userConfigFile } ` ] ;
170
149
150
+ // Support non-default output directories by making the output path (easy to get here at build-time) available to the
151
+ // server SDK's default `RewriteFrames` instance (which needs it at runtime).
171
152
if ( buildContext . isServer ) {
172
153
const rewriteFramesHelper = path . resolve (
173
154
fs . mkdtempSync ( path . resolve ( os . tmpdir ( ) , 'sentry-' ) ) ,
174
155
'rewriteFramesHelper.js' ,
175
156
) ;
176
- debugger ;
177
- // Support non-default output directories by making the output path (easy to get here at build-time) available to
178
- // the server SDK's default `RewriteFrames` instance (which needs it at runtime).
179
- fs . writeFileSync ( rewriteFramesHelper , `global.__rewriteFramesDistDir__ = '${ buildContext . config . distDir } ';\n` ) ;
180
- filesToInject . push ( rewriteFramesHelper ) ;
157
+ const buildDirAbsPath = path . resolve ( buildContext . dir , buildContext . config . distDir ) ;
158
+ fs . writeFileSync ( rewriteFramesHelper , `global.__rewriteFramesDistDir__ = '${ buildDirAbsPath } ';\n` ) ;
159
+ filesToInject . unshift ( rewriteFramesHelper ) ;
181
160
}
182
161
162
+ //
183
163
for ( const entryPointName in newEntryProperty ) {
184
164
if ( shouldAddSentryToEntryPoint ( entryPointName ) ) {
185
165
addFilesToExistingEntryPoint ( newEntryProperty , entryPointName , filesToInject ) ;
186
166
}
187
167
}
188
- //
189
- // if (buildContext.isServer) {
190
- // debugger;
191
- // rimraf(path.dirname(REWRITE_FRAMES_HELPER), err =>
192
- // logger.warn(`Could not remove ${REWRITE_FRAMES_HELPER}. Received error: ${err}`),
193
- // );
194
- // }
195
168
196
169
return newEntryProperty ;
197
170
}
0 commit comments