File tree 2 files changed +23
-1
lines changed
express-file-server/src/node
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ export class ExpressFileServerContribution implements ServerAppContribution {
30
30
return ;
31
31
}
32
32
33
+ if ( process . env . NODE_ENV === 'development' && uriPath . startsWith ( '/monaco/worker' ) ) {
34
+ const filePath = path . resolve ( __dirname , `../../../${ uriPath } ` ) ;
35
+ const contentType = ALLOW_MIME [ path . extname ( filePath ) . slice ( 1 ) ] ;
36
+ if ( ! contentType ) {
37
+ ctx . status = 404 ;
38
+ return ;
39
+ }
40
+ ctx . set ( 'Content-Type' , contentType ) ;
41
+ ctx . body = fs . createReadStream ( filePath ) ;
42
+ return ;
43
+ }
44
+
33
45
const filePath = URI . parse ( `file://${ uriPath } ` ) . codeUri . fsPath ;
34
46
const whitelist = this . getWhiteList ( ) ;
35
47
const contentType = ALLOW_MIME [ path . extname ( filePath ) . slice ( 1 ) ] ;
Original file line number Diff line number Diff line change @@ -301,7 +301,17 @@ export class MonacoClientContribution
301
301
} ;
302
302
303
303
const getWorker = ( moduleId , label ) => {
304
- const url = getWorkerUrl ( moduleId , label ) ;
304
+ let url : string ;
305
+
306
+ /**
307
+ * 开发模式下,直接使用本地文件
308
+ */
309
+ if ( process . env . NODE_ENV === 'development' ) {
310
+ url = 'assets/monaco/worker/editor.worker.bundle.js' ;
311
+ } else {
312
+ url = getWorkerUrl ( moduleId , label ) ;
313
+ }
314
+
305
315
/**
306
316
* monaco 0.53 版本开始,创建 worker 线程时都指定了 type 为 module,而我们模块格式不兼容
307
317
* 所以需要覆写 getWorker 函数,手动创建 worker 线程
You can’t perform that action at this time.
0 commit comments