Skip to content

Commit 315c343

Browse files
committed
MONACO: monaco initialization revamped.
1 parent 7177b0d commit 315c343

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/shared/config/monaco-init.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { loader } from '@monaco-editor/react';
2+
import * as monaco from 'monaco-editor';
3+
4+
// Import workers using Vite's specific worker syntax
5+
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
6+
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
7+
8+
// Configure the Monaco Environment to use local workers (Offline mode)
9+
self.MonacoEnvironment = {
10+
getWorker(_, label) {
11+
if (label === 'json') {
12+
return new jsonWorker();
13+
}
14+
return new editorWorker();
15+
},
16+
};
17+
18+
// Tell the React wrapper to use the local monaco instance
19+
loader.config({ monaco });
20+
21+
export default monaco;

0 commit comments

Comments
 (0)