We have a large javascript application that is entirely namespaced. We use require.js to load everything (require lives on the namespace) We then use grunt to compile the 100+/- js files, including libraries into one minified file.
I am able to load ace.js with
define(['ace/ace'], function (ace) {....
I am able to create an editor such as
var editor = ace.edit("editor");
I am not sure however to load the mode and theme. When I try something like..
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
The request tries to find the file at the web root.
mysite.com/theme-monokai.js
However those files need to be compiled with the rest and put into the one big minified file.
I imagine I need to include the theme and mode in my define statement, however I have tried that, and while I can get at a theme object such as
define(['ace/mode-javascript'], function (mode_js) {
console.log('mode loaded just fine')
console.log(mode_js)
...
However I don't have any luck trying to pass the object into the setTheme and setMode functions.
editor.setTheme(ace_theme);
editor.getSession().setMode(mode_js);
The end result of all of this is that I have a ace editor working but no highlighting or theme. Line numbering works, tabbing works. I am not sure if these things are in the main ace.js or if it is successfully loading its dependencies and just not able to load or not able to map the theme/mode paths to how they are loaded.
Is there a way to set the theme and mode defaults with a config? this may help. Does anyone have any idea what I am missing?
Thanks.