File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ interface MapTransformOptions {
3131 rewrite : ( path : string ) => string ;
3232 transform : Transformer ;
3333 rootPath ?: string ;
34+ rootPrefix ?: string ;
3435}
3536
3637function scanFile (
@@ -64,7 +65,8 @@ function replacePaths(
6465 paths : TransformedPaths ,
6566 stash : FileStash ,
6667 search : RegExp ,
67- rootPath ?: string
68+ rootPath ?: string ,
69+ rootPrefix ?: string
6870) {
6971 for ( const p in paths ) {
7072 if ( paths . hasOwnProperty ( p ) ) {
@@ -74,9 +76,13 @@ function replacePaths(
7476
7577 if ( item . realPath === p ) {
7678 content = content . replace ( search , ( match ) => {
79+ const prefix = typeof rootPrefix === 'string'
80+ ? rootPrefix
81+ : ( rootPath ? '/' : '' )
82+
7783 return match . replace (
7884 item . virtPath ,
79- ( rootPath ? '/' : '' ) + path . relative (
85+ prefix + path . relative (
8086 rootPath || path . dirname ( fromPath ) ,
8187 paths [ p ]
8288 )
@@ -177,7 +183,8 @@ function mapTransform(options: MapTransformOptions) {
177183 transformedPaths ,
178184 fileStash ,
179185 options . search ,
180- options . rootPath
186+ options . rootPath ,
187+ options . rootPrefix
181188 )
182189 ) ;
183190 }
You can’t perform that action at this time.
0 commit comments