TinyMCE, poltergist, and minification

We’re working on a project now that needs a good WYSWIG type editor. Our old favourite, TinyMCE, wins the spot. TinyMCE, of course, is Javascript and so we need Capybara to run Poltergeist to be able to test.

Minified TinyMCE downloaded and installed. Runs fine in a browser from localhost, but then fails to load in Poltergeist, stating that it couldn’t find its files. For some reason, it was looking relative to the root path. You can use the baseURL attribute in settings to point to a direct location, though.

That solved the location problem, but then produced errors like:


...
Failed to load: /javascripts/lib/tinymce/plugins/save/plugin.js
Failed to load: /javascripts/lib/tinymce/plugins/autoresize/plugin.js
...

Notice the lack of a .min.js extension? What wasn’t made clear in the SO post is that baseURL must be paired with the suffix attribute to load minified files:

tinymce.baseURL = '/javascripts/lib/tinymce';
tinymce.suffix = '.min';

There you go: I just saved you a half-day of annoyance. Exit through the gift shop.

It’s a little gross if you need to switch between full and minified, and there may be a better setting to use, but I’ve spent too much time on this problem already. If you know a better way, feel free to drop me a line.