File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 13
13
"build:src" : " tsc" ,
14
14
"build:electron" : " npm run server:setup && electron-builder build" ,
15
15
"build:dir-only" : " npm run server:setup && electron-builder --dir" ,
16
+ "postbuild" : " ts-node ./strip-preload-map.ts" ,
16
17
"start" : " npm run server:setup && npm run start:app" ,
17
18
"start:dev" : " ts-node ./skip-server.ts && cross-env HTK_DEV=true APP_URL='http://local.httptoolkit.tech:8080' npm run start:app" ,
18
19
"start:app" : " tsc-watch --onSuccess \" electron .\" "
Original file line number Diff line number Diff line change
1
+ import * as path from 'path' ;
2
+ import { readFileSync , writeFileSync } from 'fs' ;
3
+
4
+ function removeSourceMapAnnotation ( filePath : string ) : void {
5
+ const fileContent = readFileSync ( filePath , 'utf8' ) ;
6
+ const lines = fileContent . split ( '\n' ) ;
7
+
8
+ if ( lines [ lines . length - 1 ] . startsWith ( '//# sourceMappingURL=' ) ) {
9
+ lines . pop ( ) ; // Remove the last line
10
+ } else {
11
+ console . log ( `No sourcemap annotation found in ${ filePath } ` ) ;
12
+ return ;
13
+ }
14
+
15
+ const newContent = lines . join ( '\n' ) ;
16
+ writeFileSync ( filePath , newContent , 'utf8' ) ;
17
+ console . log ( `Sourcemap annotation removed from ${ filePath } ` ) ;
18
+ }
19
+
20
+ // We have to strip the source map comment from here, otherwise when it loads
21
+ // in Chrome, it tries to get preload.js.map from the real server, leaving
22
+ // us with an annoying error because that's never going to work.
23
+ const filePath = path . join ( __dirname , 'build' , 'preload.js' ) ;
24
+ removeSourceMapAnnotation ( filePath ) ;
You can’t perform that action at this time.
0 commit comments