@@ -11,37 +11,43 @@ export function getWebpackPluginOptions(
11
11
buildContext : BuildContext ,
12
12
sentryBuildOptions : SentryBuildOptions ,
13
13
) : SentryWebpackPluginOptions {
14
- const { buildId, isServer, config : userNextConfig , dir : projectDir , nextRuntime } = buildContext ;
14
+ const { buildId, isServer, config : userNextConfig , dir, nextRuntime } = buildContext ;
15
15
16
16
const prefixInsert = ! isServer ? 'Client' : nextRuntime === 'edge' ? 'Edge' : 'Node.js' ;
17
17
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 ) ;
19
25
20
26
let sourcemapUploadAssets : string [ ] = [ ] ;
21
27
const sourcemapUploadIgnore : string [ ] = [ ] ;
22
28
23
29
if ( isServer ) {
24
30
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
27
33
) ;
28
34
} else {
29
35
if ( sentryBuildOptions . widenClientFileUpload ) {
30
- sourcemapUploadAssets . push ( path . join ( distDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
36
+ sourcemapUploadAssets . push ( path . posix . join ( distDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
31
37
} else {
32
38
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' , '**' ) ,
35
41
) ;
36
42
}
37
43
38
44
// TODO: We should think about uploading these when `widenClientFileUpload` is `true`. They may be useful in some situations.
39
45
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-*' ) ,
45
51
) ;
46
52
}
47
53
@@ -79,9 +85,9 @@ export function getWebpackPluginOptions(
79
85
// We only care to delete client bundle source maps because they would be the ones being served.
80
86
// Removing the server source maps crashes Vercel builds for (thus far) unknown reasons:
81
87
// 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' ) ,
85
91
]
86
92
: undefined ,
87
93
...sentryBuildOptions . unstable_sentryWebpackPluginOptions ?. sourcemaps ,
0 commit comments