@@ -635,8 +635,8 @@ function setUpModuleRules(newConfig: WebpackConfigObject): WebpackConfigObjectWi
635635} 
636636
637637/** 
638-  * Support the `distDir` option  by making its value  (easy to get here at build-time) available to the server SDK's  
639-  * default `RewriteFrames` instance (which needs it at runtime ), by injecting code to attach it  to `global`. 
638+  * Support the `distDir` and `assetPrefix` options  by making their values  (easy to get here at build-time) available at  
639+  * runtime (for use by `RewriteFrames` ), by injecting code to attach their values  to `global` or `window `. 
640640 * 
641641 * @param  newConfig The webpack config object being constructed 
642642 * @param  target Either 'server' or 'client' 
@@ -656,6 +656,16 @@ function addRewriteFramesLoader(
656656        userNextConfig . distDir ?. replace ( / \\ / g,  '\\\\' )  ||  '.next' , 
657657      ] , 
658658    ] , 
659+     client : [ 
660+       [ 
661+         '__ASSET_PREFIX_PATH__' , 
662+         // Get the path part of `assetPrefix`, minus any trailing slash. (We use a placeholder for the origin if 
663+         // `assetPreix` doesn't include one. Since we only care about the path, it doesn't matter what it is.) 
664+         userNextConfig . assetPrefix 
665+           ? new  URL ( userNextConfig . assetPrefix ,  'http://dogs.are.great' ) . pathname . replace ( / \/ $ / ,  '' ) 
666+           : '' , 
667+       ] , 
668+     ] , 
659669  } ; 
660670
661671  newConfig . module . rules . push ( { 
@@ -665,8 +675,7 @@ function addRewriteFramesLoader(
665675        loader : path . resolve ( __dirname ,  'loaders/prefixLoader.js' ) , 
666676        options : { 
667677          templatePrefix : `${ target }  , 
668-           // This weird cast will go away as soon as we add the client half of this function in 
669-           replacements : replacements [ target  as  'server' ] , 
678+           replacements : replacements [ target ] , 
670679        } , 
671680      } , 
672681    ] , 
0 commit comments