diff --git a/vite.config.js b/vite.config.js index 678a256..6377465 100644 --- a/vite.config.js +++ b/vite.config.js @@ -23,14 +23,13 @@ export default defineConfig(({ mode, command }) => { plugins: createVitePlugins(env, command === 'build'), optimizeDeps: { exclude: [ - ...(isCommonLinked ? ['@cmvr/iot-common'] : []), - 'monaco-editor', - 'monaco-editor/esm/vs/base/worker/workerMain.js', - 'monaco-editor/esm/vs/editor/editor.main.js', - 'ts.worker.js', - 'typescript' + ...(isCommonLinked ? ['@cmvr/iot-common'] : []) ], include: [ + 'monaco-editor/esm/vs/editor/editor.all.js', + 'monaco-editor/esm/vs/editor/editor.api.js', + 'monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js', + 'monaco-editor/esm/vs/language/json/monaco.contribution.js', 'monaco-editor/esm/vs/language/typescript/monaco.contribution' ] }, @@ -55,8 +54,8 @@ export default defineConfig(({ mode, command }) => { chunkSizeWarningLimit: 2000, rollupOptions: { output: { - manualChunks: { - monaco: ['monaco-editor'] + manualChunks(id) { + if (id.includes('/node_modules/monaco-editor/')) return 'monaco' }, chunkFileNames: 'static/js/[name]-[hash].js', entryFileNames: 'static/js/[name]-[hash].js', diff --git a/vite/plugins/index.js b/vite/plugins/index.js index fede791..e614915 100644 --- a/vite/plugins/index.js +++ b/vite/plugins/index.js @@ -12,7 +12,7 @@ export default function createVitePlugins(viteEnv, isBuild = false) { const vitePlugins = [ vue(), monacoEditorPlugin({ - languages: ['javascript', 'html', 'css', 'json', 'python', 'java'] + languageWorkers: ['editorWorkerService', 'json', 'typescript'] }) ] vitePlugins.push(createAutoImport())