mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix: optimize monaco-editor loading (locally)
This commit is contained in:
1 parent
ca47590376
commit
eb401042a6
3 files changed
+6
-9
No files matched your search
@@ -4,9 +4,6 @@ import { createHead } from '@vueuse/head';
|
||||
import { library } from '@fortawesome/fontawesome-svg-core';
|
||||
import { fas } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { install as VueMonacoEditorPlugin, loader } from '@guolao/vue-monaco-editor';
|
||||
import * as monaco from 'monaco-editor';
|
||||
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
import shadow from 'vue-shadow-dom';
|
||||
import { plausible } from './plugins/plausible.plugin';
|
||||
@@ -23,14 +20,10 @@ import store from './tools/pomodoro-timer/app/store';
|
||||
|
||||
library.add(fas);
|
||||
|
||||
// loaded monaco-editor from `node_modules`
|
||||
loader.config({ monaco });
|
||||
|
||||
registerSW();
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(VueMonacoEditorPlugin);
|
||||
app.use(createPinia());
|
||||
app.use(createHead());
|
||||
app.use(i18nPlugin);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import * as monacoEditor from 'monaco-editor';
|
||||
import { VueMonacoEditor, loader } from '@guolao/vue-monaco-editor';
|
||||
import type { MonacoEditor } from '@guolao/vue-monaco-editor';
|
||||
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
@@ -53,6 +54,9 @@ globalThis.MonacoEnvironment = {
|
||||
},
|
||||
};
|
||||
|
||||
// loaded monaco-editor from `node_modules`
|
||||
loader.config({ monaco: monacoEditor });
|
||||
|
||||
export interface EditorProps {
|
||||
defaultValue?: string
|
||||
defaultPath?: string
|
||||
@@ -113,7 +117,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<vue-monaco-editor
|
||||
<VueMonacoEditor
|
||||
v-bind="inheritedAttrs"
|
||||
v-model:value="value"
|
||||
@before-mount="(monaco: MonacoEditor) => emits('beforeMount', monaco)"
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ export default defineConfig({
|
||||
output: {
|
||||
format: 'es',
|
||||
manualChunks: (id) => {
|
||||
if (id.includes('monaco-editor')) return 'monaco-editor';
|
||||
// if (id.includes('monaco-editor')) return 'monaco-editor';
|
||||
if (id.includes('tesseract.js')) return 'tesseract.js';
|
||||
if (id.includes('pdfjs')) return 'pdfjs';
|
||||
if (id.includes('unicode')) return 'unicode';
|
||||
|
||||
Reference in new issue
Block a user