简体   繁体   English

我如何在我的反应构建中为摩纳哥编辑器的 loader.js 及其对本地主机的依赖项提供服务

[英]How do I serve Monaco editor's loader.js and its dependencies on localhost in my react build

I am using Monaco Monaco Editor .我正在使用 Monaco Monaco Editor After building and serving code on localhost, The Loader Script is loading from CDN在本地主机上构建和提供代码后,加载脚本从 CDN 加载

截屏

How can I include the files in the build?如何在构建中包含这些文件?

use monaco-editor as an npm package 使用 monaco-editor 作为 npm 包

Starting from version v4.4.0 it's possible to use monaco-editor as an npm package;从版本 v4.4.0 开始,可以将 monaco-editor 作为 npm 包使用; import it from node_modules and include monaco sources into your bundle (instead of using CDN).从 node_modules 导入它并将摩纳哥源代码包含到您的包中(而不是使用 CDN)。 To make it work you can do the following:要使其工作,您可以执行以下操作:

import { loader } from "@monaco-editor/react";
import * as monaco from "monaco-editor";
loader.config({ monaco });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ngx-monaco-editor:无法从 node_modules 找到 loader.js 文件 - ngx-monaco-editor : unable to find loader.js file from node_modules 如何将文本插入摩纳哥编辑器? - How do I insert text into a Monaco Editor? 在反应应用程序中运行 npm start 后,我​​有这个错误:internal/modules/cjs/loader.js:834 - After running npm start in react application I have this error: internal/modules/cjs/loader.js:834 如何在 React 中获取嵌入式 Monaco 编辑器的行数? (包括包装) - How do I get the line count of an embedded Monaco editor in React? (including wrapping) 摩纳哥编辑依赖性问题 - Monaco Editor Dependencies Issue 如何在gstatic loader.js Google图表库中添加回调? - How to add callback to gstatic loader.js google charts library? 如何使用 API 在 Monaco Editor 中格式化 JSON 代码? - How do I format JSON code in Monaco Editor with API? 如何将 javascript 自动完成添加到摩纳哥编辑器的 markdown 模式? - How do I add javascript autocomplete to markdown mode of monaco editor? 如何在 React 功能组件中使用 Monaco Editor? - How to use Monaco Editor in a React functional component? 将 monaco-editor 和 monaco-languageclient 包装为 React 组件时,对“vscode”的奇怪的未解决依赖项 - Strange Unresolved dependencies to 'vscode' when wrapping monaco-editor and monaco-languageclient as a react component
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM