Running editor.setTheme('libs/ace/theme/twilight')
will look for theme-twilight.js
in the root folder.
I tried looking at the documentation without finding any help.
Also, the workers, are they required for any languages, or is there an option to turn them off?
Again, found no solution to this in the docs.
After searching for a good while I found these two:
ace.config.set('basePath', '/libs/ace');
editor.getSession().setUseWorker(false);
You are a hero, needed that basePath property and had been looking for days. Thank you.
For future reference, this is a complete example (modeled after the embedding example on the official ace website) for having ace.js somewhere else (I had it concatenated into a libs.min.js):
<script src="libs.min.js" type="text/javascript" charset="utf-8"></script>
<script>
ace.config.set('basePath', '/ace-builds/src-noconflict');
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
</script>
For anyone who struggles to get this to work in production environments, I've found that not only setting basePath
, but also setting modePath
and themePath
are sometimes necessary for loading modes and themes:
ace.config.set('basePath', '/ace-builds/src-noconflict');
ace.config.set('modePath', '/ace-builds/src-noconflict');
ace.config.set('themePath', '/ace-builds/src-noconflict');
@efatsi Can u please share with me how can we do it angular 6 project with https://github.com/fxmontigny/ng2-ace-editor . I am also facing the same issue.
Sorry @PrabakarKaruppasamy, I don't have any angular experience. good luck!
@PrabakarKaruppasamy - were you able to make it work mate? Any change you could look at https://stackoverflow.com/questions/60177855/theme-and-mode-path-infer-issue-with-ace-js-and-angular
Most helpful comment
After searching for a good while I found these two:
ace.config.set('basePath', '/libs/ace');
editor.getSession().setUseWorker(false);