Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACE editor with webpack

How can I use ACE editor with webpack ? ACE editor can load extensions like syntax highlights, or code snippets dynamically. But, webpack tries to load scripts statically.

like image 280
Tsuneo Yoshioka Avatar asked Oct 17 '22 18:10

Tsuneo Yoshioka


1 Answers

You could use brace which is browserify compatible

npm install --save brace

Then in one of your javascript files you can include it like so

var brace = require('brace'); require('brace/mode/javascript'); require('brace/theme/monokai');

If your using webpack with es6 you can do

import brace from 'brace' import 'brace/mode/javascript' import 'brace/theme/monokai'

You can see more here - https://www.npmjs.com/package/brace

I use a react wrapper of ace which can be found here

https://github.com/securingsincity/react-ace

like image 63
el-davo Avatar answered Oct 20 '22 09:10

el-davo