imguolao / monaco-vue

Use monaco-editor loaded from CDN in Vue 2&3, no need to bundling.
https://imguolao.github.io/monaco-vue/
MIT License
234 stars 21 forks source link

Monaco initialization error: no such file or directory, open 'https:/cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs/editor/editor.main.js' #36

Closed mx94 closed 1 year ago

mx94 commented 1 year ago

image

mx94 commented 1 year ago

image

mx94 commented 1 year ago

在electron中使用vite构建,CDN引入后报找不到路径,https:/ 为啥会少了个斜杠 :(

imguolao commented 1 year ago

Oh, sry!

This is a known issue, but I forgot to put it in the documentation.

Look at here.

mx94 commented 1 year ago

thank you!

` import { createApp } from 'vue' import { install as VueMonacoEditorPlugin, loader } from '@guolao/vue-monaco-editor' import * as monaco from 'monaco-editor' import App from './App.vue' import '@assets/css/styles.css'

import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker' import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker' import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'

self.MonacoEnvironment = { getWorker(_, label) { if (label === 'json') { return new jsonWorker() } if (label === 'css' || label === 'scss' || label === 'less') { return new cssWorker() } if (label === 'html' || label === 'handlebars' || label === 'razor') { return new htmlWorker() } if (label === 'typescript' || label === 'javascript') { return new tsWorker() } return new editorWorker() }, }

loader.config({ monaco }) const app = createApp(App) app.use(VueMonacoEditorPlugin) app.mount('#app')

`