如何让Ace不再寻找当前目录中的主题和模式? [英] How to Keep Ace from Looking for Themes and Modes in Current Directory?

查看:460
本文介绍了如何让Ace不再寻找当前目录中的主题和模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于使用Cloud9提供的Ace浏览器代码编辑器的MVC Web应用程序。 ace.js脚本和设置ace编辑器的脚本都在我的BundleConfig上的ScriptBundle中。捆绑正在装载完美。在我的本地服务器上,在web.config中将debug设置为true,脚本运行得非常好。但是,在web.config中启动调试设置为false的实时服务器后,出现了几个错误。

I've been working on an MVC web application that uses the Ace in-browser code editor provided by Cloud9. The ace.js script and a script that sets up ace's editor are both in a ScriptBundle together on my BundleConfig. The bundle is being loaded perfectly fine. On my local server, with debug set to true in the web.config, the script worked perfectly fine. However, after launching to a live server with debug set to false in the web.config, several errors appeared.

修复了一些小错误后,仍有两个错误我似乎无法理解其原因。这两个错误看起来非常相似,因为它们是Ace的chrome主题和Ace的HTML模式脚本都没有找到404错误。在设置编辑器的脚本中,它们的调用方式如下:

After fixing a few minor glitches, there remain two errors that I can't seem to understand the cause of. These two errors seem very similar, as they are both 404 not found errors for Ace's chrome theme and Ace's HTML mode scripts. In the script that sets up the editor, they are called as follows:

editor.setTheme("ace/theme/chrome");
editor.getSession().setMode("ace/mode/html");

在我的本地计算机上,将调试设置为true,主题和模式设置得非常好,一切都按计划进行。但是,正如我所说,在调试设置为false的实时服务器上,因此缩小了ScriptBundles中的所有脚本,主题和模式都出现了404错误。

On my local computer, with debugging set to true, the theme and the mode are set perfectly fine, and everything works as planned. However, as I've said, on a live server with debugging set to false, therefore minifying all of the scripts in my ScriptBundles, I get a 404 error for both the theme and the mode.

当我在谷歌浏览器中启动JavaScript控制台时,我被告知两个404错误。有关404错误的有趣之处在于它们链接到我正在查看的页面的当前目录,然后分别是theme-chrome.js和mode-html.js。他们从来没有在那个目录中,但仍然没有。

When I pull up the JavaScript Console in Google Chrome, I am told of the two 404 errors. The funny thing about the 404 errors, is that they are linking to the current directory of the page I'm viewing, then followed by "theme-chrome.js" and "mode-html.js" respectively. They were never in that directory, and still aren't.

所以我的问题是为什么脚本在缩小后开始在当前目录中查找他们的文件?我该怎么做才能解决这个问题,以便我可以将它们缩小,捆绑在一起,让它们工作?或者有办法吗?

So my question is why do the scripts begin to look in the current directory for their files after being minified? What can I do to fix this issue so that I can keep them minified, in bundles, and have them work? Or is there a way?

提前感谢您的帮助。

推荐答案

我发现使用Ace和MVC Bundling和Minification,我需要使用绝对引用在ace配置中设置basePath。

I find with Ace and MVC Bundling and Minification, I need to set the basePath in the ace configuration using an absolute reference.

ace.config.set("basePath", "/Scripts/FullPathToMy/AceEditorDirectory");

这可能不是最好的解决方案,但它应该让你顺利。

It's probably not the best solution, but it should get you on your way.

这篇关于如何让Ace不再寻找当前目录中的主题和模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆