File tree Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Expand file tree Collapse file tree 2 files changed +12
-22
lines changed Original file line number Diff line number Diff line change 11import { loader } from '@monaco-editor/react' ;
2- import * as monaco from 'monaco-editor' ;
3- import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' ;
4- import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' ;
5- import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker' ;
6- import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker' ;
7- import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' ;
2+ import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js" ;
3+ import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' ;
84
9- // Reference: https://github.com/suren-atoyan/monaco-react?tab=readme-ov-file#use-monaco-editor-as-an-npm-package
105self . MonacoEnvironment = {
11- getWorker ( _ , label ) {
12- if ( label === 'json' ) {
13- return new jsonWorker ( ) ;
14- }
15- if ( label === 'css' || label === 'scss' || label === 'less' ) {
16- return new cssWorker ( ) ;
17- }
18- if ( label === 'html' || label === 'handlebars' || label === 'razor' ) {
19- return new htmlWorker ( ) ;
20- }
21- if ( label === 'typescript' || label === 'javascript' ) {
22- return new tsWorker ( ) ;
23- }
24- return new editorWorker ( ) ;
25- } ,
6+ getWorker : ( ) => {
7+ return new EditorWorker ( ) ;
8+ } ,
269} ;
2710
2811loader . config ( { monaco } ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ export default defineConfig({
77 base : "./" ,
88 build : {
99 target : "esnext" ,
10+ rollupOptions : {
11+ output : {
12+ manualChunks : {
13+ "monaco-editor" : [ "monaco-editor" ] ,
14+ } ,
15+ } ,
16+ } ,
1017 } ,
1118 plugins : [
1219 react ( ) ,
You can’t perform that action at this time.
0 commit comments