File tree Expand file tree Collapse file tree 5 files changed +58
-9
lines changed Expand file tree Collapse file tree 5 files changed +58
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
Starting from GraphiQL 5, you need to set up Monaco workers in your project:
4
4
5
- - For ** Vite** projects you must import :
5
+ - For ** Vite** projects you must:
6
6
7
- ``` js
8
- import ' graphiql/setup-workers/vite' ;
7
+ 1 . Install ` vite-plugin-monaco-editor ` package:
8
+
9
+ ``` sh
10
+ npm install vite-plugin-monaco-editor --save-dev
11
+ ```
12
+
13
+ 2 . Import and configure the plugin in your ` vite.config.mjs ` file:
14
+
15
+ ``` diff
16
+ // vite.config.mjs
17
+ import { defineConfig } from 'vite'
18
+ import react from '@vitejs/plugin-react'
19
+ +import $monacoEditorPlugin from 'vite-plugin-monaco-editor'
20
+
21
+ +const monacoEditorPlugin = $monacoEditorPlugin.default ?? $monacoEditorPlugin
22
+
23
+ export default defineConfig({
24
+ plugins: [
25
+ react(),
26
+ + monacoEditorPlugin({
27
+ + languageWorkers: ['editorWorkerService', 'json'],
28
+ + customWorkers: [
29
+ + {
30
+ + label: 'graphql',
31
+ + entry: 'monaco-graphql/esm/graphql.worker.js'
32
+ + }
33
+ + ]
34
+ + })
35
+ ]
36
+ })
9
37
```
10
38
11
39
> [ !NOTE]
Original file line number Diff line number Diff line change 10
10
},
11
11
"devDependencies" : {
12
12
"@vitejs/plugin-react" : " ^4.4.1" ,
13
- "vite" : " ^6.3.4"
13
+ "vite" : " ^6.3.4" ,
14
+ "vite-plugin-monaco-editor" : " ^1.1.0"
14
15
},
15
16
"scripts" : {
16
17
"dev" : " vite" ,
Original file line number Diff line number Diff line change 1
1
import { GraphiQL } from 'graphiql' ;
2
- import 'graphiql/setup-workers/vite' ;
3
2
import 'graphiql/style.css' ;
4
3
5
4
async function fetcher ( graphQLParams ) {
Original file line number Diff line number Diff line change 1
1
import { defineConfig } from 'vite' ;
2
2
import react from '@vitejs/plugin-react' ;
3
+ import $monacoEditorPlugin from 'vite-plugin-monaco-editor' ;
4
+
5
+ const monacoEditorPlugin = $monacoEditorPlugin . default ?? $monacoEditorPlugin ;
3
6
4
7
export default defineConfig ( {
5
- plugins : [ react ( ) ] ,
6
- worker : {
7
- format : 'es' ,
8
- } ,
8
+ plugins : [
9
+ react ( ) ,
10
+ monacoEditorPlugin ( {
11
+ languageWorkers : [ 'editorWorkerService' , 'json' ] ,
12
+ customWorkers : [
13
+ {
14
+ label : 'graphql' ,
15
+ entry : 'monaco-graphql/esm/graphql.worker.js' ,
16
+ } ,
17
+ ] ,
18
+ } ) ,
19
+ ] ,
9
20
} ) ;
Original file line number Diff line number Diff line change @@ -12611,6 +12611,7 @@ __metadata:
12611
12611
react: "npm:^19.1.0"
12612
12612
react-dom: "npm:^19.1.0"
12613
12613
vite: "npm:^6.3.4"
12614
+ vite-plugin-monaco-editor: "npm:^1.1.0"
12614
12615
languageName: unknown
12615
12616
linkType: soft
12616
12617
@@ -24790,6 +24791,15 @@ __metadata:
24790
24791
languageName: node
24791
24792
linkType: hard
24792
24793
24794
+ "vite-plugin-monaco-editor@npm:^1.1.0":
24795
+ version: 1.1.0
24796
+ resolution: "vite-plugin-monaco-editor@npm:1.1.0"
24797
+ peerDependencies:
24798
+ monaco-editor: ">=0.33.0"
24799
+ checksum: 10c0/1f0d839c194d79f21f4ef192d19d82e42ed6dbbab580df684db2e4eeb01d1f2e9c572e9e5b50e9887e9028a54514c496ee6db9d68cab579d375d09456d8b91ee
24800
+ languageName: node
24801
+ linkType: hard
24802
+
24793
24803
"vite-plugin-svgr@npm:^4.3.0":
24794
24804
version: 4.3.0
24795
24805
resolution: "vite-plugin-svgr@npm:4.3.0"
You can’t perform that action at this time.
0 commit comments