mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 21:44:40 +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 { library } from '@fortawesome/fontawesome-svg-core';
|
||||||
import { fas } from '@fortawesome/free-solid-svg-icons';
|
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 { registerSW } from 'virtual:pwa-register';
|
||||||
import shadow from 'vue-shadow-dom';
|
import shadow from 'vue-shadow-dom';
|
||||||
import { plausible } from './plugins/plausible.plugin';
|
import { plausible } from './plugins/plausible.plugin';
|
||||||
@@ -23,14 +20,10 @@ import store from './tools/pomodoro-timer/app/store';
|
|||||||
|
|
||||||
library.add(fas);
|
library.add(fas);
|
||||||
|
|
||||||
// loaded monaco-editor from `node_modules`
|
|
||||||
loader.config({ monaco });
|
|
||||||
|
|
||||||
registerSW();
|
registerSW();
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
app.use(VueMonacoEditorPlugin);
|
|
||||||
app.use(createPinia());
|
app.use(createPinia());
|
||||||
app.use(createHead());
|
app.use(createHead());
|
||||||
app.use(i18nPlugin);
|
app.use(i18nPlugin);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import * as monacoEditor from 'monaco-editor';
|
import * as monacoEditor from 'monaco-editor';
|
||||||
|
import { VueMonacoEditor, loader } from '@guolao/vue-monaco-editor';
|
||||||
import type { MonacoEditor } 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 EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||||
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.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 {
|
export interface EditorProps {
|
||||||
defaultValue?: string
|
defaultValue?: string
|
||||||
defaultPath?: string
|
defaultPath?: string
|
||||||
@@ -113,7 +117,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<vue-monaco-editor
|
<VueMonacoEditor
|
||||||
v-bind="inheritedAttrs"
|
v-bind="inheritedAttrs"
|
||||||
v-model:value="value"
|
v-model:value="value"
|
||||||
@before-mount="(monaco: MonacoEditor) => emits('beforeMount', monaco)"
|
@before-mount="(monaco: MonacoEditor) => emits('beforeMount', monaco)"
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ export default defineConfig({
|
|||||||
output: {
|
output: {
|
||||||
format: 'es',
|
format: 'es',
|
||||||
manualChunks: (id) => {
|
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('tesseract.js')) return 'tesseract.js';
|
||||||
if (id.includes('pdfjs')) return 'pdfjs';
|
if (id.includes('pdfjs')) return 'pdfjs';
|
||||||
if (id.includes('unicode')) return 'unicode';
|
if (id.includes('unicode')) return 'unicode';
|
||||||
|
|||||||
Reference in new issue
Block a user