@@ -11,37 +11,43 @@ export function getWebpackPluginOptions(
1111 buildContext : BuildContext ,
1212 sentryBuildOptions : SentryBuildOptions ,
1313) : SentryWebpackPluginOptions {
14- const { buildId, isServer, config : userNextConfig , dir : projectDir , nextRuntime } = buildContext ;
14+ const { buildId, isServer, config : userNextConfig , dir, nextRuntime } = buildContext ;
1515
1616 const prefixInsert = ! isServer ? 'Client' : nextRuntime === 'edge' ? 'Edge' : 'Node.js' ;
1717
18- const distDirAbsPath = path . join ( projectDir , ( userNextConfig as NextConfigObject ) . distDir || '.next' ) ; // `.next` is the default directory
18+ // We need to convert paths to posix because Glob patterns use `\` to escape
19+ // glob characters. This clashes with Windows path separators.
20+ // See: https://www.npmjs.com/package/glob
21+ const projectDir = dir . replace ( / \\ / g, '/' ) ;
22+ // `.next` is the default directory
23+ const distDir = ( userNextConfig as NextConfigObject ) . distDir ?. replace ( / \\ / g, '/' ) ?? '.next' ;
24+ const distDirAbsPath = path . posix . join ( projectDir , distDir ) ;
1925
2026 let sourcemapUploadAssets : string [ ] = [ ] ;
2127 const sourcemapUploadIgnore : string [ ] = [ ] ;
2228
2329 if ( isServer ) {
2430 sourcemapUploadAssets . push (
25- path . join ( distDirAbsPath , 'server' , '**' ) , // This is normally where Next.js outputs things
26- path . join ( distDirAbsPath , 'serverless' , '**' ) , // This was the output location for serverless Next.js
31+ path . posix . join ( distDirAbsPath , 'server' , '**' ) , // This is normally where Next.js outputs things
32+ path . posix . join ( distDirAbsPath , 'serverless' , '**' ) , // This was the output location for serverless Next.js
2733 ) ;
2834 } else {
2935 if ( sentryBuildOptions . widenClientFileUpload ) {
30- sourcemapUploadAssets . push ( path . join ( distDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
36+ sourcemapUploadAssets . push ( path . posix . join ( distDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
3137 } else {
3238 sourcemapUploadAssets . push (
33- path . join ( distDirAbsPath , 'static' , 'chunks' , 'pages' , '**' ) ,
34- path . join ( distDirAbsPath , 'static' , 'chunks' , 'app' , '**' ) ,
39+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'pages' , '**' ) ,
40+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'app' , '**' ) ,
3541 ) ;
3642 }
3743
3844 // TODO: We should think about uploading these when `widenClientFileUpload` is `true`. They may be useful in some situations.
3945 sourcemapUploadIgnore . push (
40- path . join ( distDirAbsPath , 'static' , 'chunks' , 'framework-*' ) ,
41- path . join ( distDirAbsPath , 'static' , 'chunks' , 'framework.*' ) ,
42- path . join ( distDirAbsPath , 'static' , 'chunks' , 'main-*' ) ,
43- path . join ( distDirAbsPath , 'static' , 'chunks' , 'polyfills-*' ) ,
44- path . join ( distDirAbsPath , 'static' , 'chunks' , 'webpack-*' ) ,
46+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework-*' ) ,
47+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework.*' ) ,
48+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'main-*' ) ,
49+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'polyfills-*' ) ,
50+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'webpack-*' ) ,
4551 ) ;
4652 }
4753
@@ -79,9 +85,9 @@ export function getWebpackPluginOptions(
7985 // We only care to delete client bundle source maps because they would be the ones being served.
8086 // Removing the server source maps crashes Vercel builds for (thus far) unknown reasons:
8187 // https://github.com/getsentry/sentry-javascript/issues/13099
82- path . join ( distDirAbsPath , 'static' , '**' , '*.js.map' ) ,
83- path . join ( distDirAbsPath , 'static' , '**' , '*.mjs.map' ) ,
84- path . join ( distDirAbsPath , 'static' , '**' , '*.cjs.map' ) ,
88+ path . posix . join ( distDirAbsPath , 'static' , '**' , '*.js.map' ) ,
89+ path . posix . join ( distDirAbsPath , 'static' , '**' , '*.mjs.map' ) ,
90+ path . posix . join ( distDirAbsPath , 'static' , '**' , '*.cjs.map' ) ,
8591 ]
8692 : undefined ,
8793 ...sentryBuildOptions . unstable_sentryWebpackPluginOptions ?. sourcemaps ,
0 commit comments