我正试图将摩纳哥配置为一个网络组件(使用vite的lit-ts模板(,它可以编辑单一的自定义语言,并且没有摩纳哥的许多额外功能。(然后我想复制输出,在我的主项目的index.html中使用脚本标记将其包括在内(
在我的主文件中,我有
import {monaco} from "./customMonaco";
// add support for the 1 custom language I do want
import "./mix.contribution.js";
在customMonaco.ts中,我有
import "monaco-editor/esm/vs/editor/browser/viewParts/contentWidgets/contentWidgets.js";
import "monaco-editor/esm/vs/editor/browser/viewParts/lineNumbers/lineNumbers.js";
import "monaco-editor/esm/vs/editor/browser/viewParts/lineNumbers/lineNumbers.css";
import "monaco-editor/esm/vs/editor/browser/viewParts/linesDecorations/linesDecorations.js";
import "monaco-editor/esm/vs/editor/browser/viewParts/linesDecorations/linesDecorations.css";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
export {monaco};
但当我构建这个时,我仍然会得到所有的语言文件。
我的vite配置是
export default defineConfig({
build: {
lib: {
entry: 'src/rmx-monaco.ts',
formats: ['es']
},
rollupOptions: {
external: /^lit/,
// output: {
// manualChunks: undefined,
// inlineDynamicImports: true,
// entryFileNames: "[name].js",
// // Prevent vendor.js being created
// // prevents adding cache busting
// chunkFileNames: "assets/[name].js",
// assetFileNames: "rmx-monaco.[ext]",
// },
}
}, server: {port: 5000}
})
接下来我将取消对输出部分的注释,以便只获得1个js文件,但我不希望它包含语言支持
monaco-editor
repo中有一个例子就是这样。查看index.js
。当前示例在..
中使用node_modules
,因此导入与最新的monaco有点不同,但如果您:
cd monaco-editor/samples
npm install monaco-editor@0.37.1
cd browser-esm-webpack-small
npm run generate-imports
它将更新index.js以使用与monaco版本一起使用的导入。
我正在使用:
import 'monaco-editor/esm/vs/editor/browser/coreCommands.js';
import 'monaco-editor/esm/vs/editor/contrib/find/browser/findController.js';
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
import 'monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'