spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
812 stars 256 forks source link

Tinymce assets do not get cached by the assets pipeline #164

Open jaroslawr opened 9 years ago

jaroslawr commented 9 years ago

I use tinymce-rails because it is included as a dependency in the comfortable-mexican-sofa gem. Every time I run an update on one of the servers, "rake assets:precompile" is run. The problem now is that every time this command is run, it recompiles the tinymce assets from scratch even though obviously nothing has changed, and this takes a longer while to execute, slowing down all the deploys, which if you do several of those a day, is noticeable. I do have a lot of other javascript and css libraries included via gems, and the problem only occurs with tinymce-rails.

I am not sure what is the reason for it, but I suspect it might because of the dynamic preinit.js.erb file that is included by all the other files. If you could extract that code into a helper that people put into their layout files, perhaps the caching would start to work correctly.

spohlenz commented 9 years ago

I've been working on an alternate asset compilation method in the compile-assets branch which works much more closely with the Sprockets compilation process. In Rails 3.x this was painfully slow but now that Rails 4.x is well and truly the version to be using, it's about time this was updated.

In this branch, the TinyMCE assets are added to the Sprockets load paths, and there is a post-install step to create non-digested symlinks which TinyMCE needs for dynamic loading.

If you are able, it'd be great if you could test it out before I merge it into master.

jaroslawr commented 9 years ago

I tested it, works very well for me, thank you!

phlegx commented 9 years ago

:+1: Is this merged in the master?

phlegx commented 9 years ago

I have tested this branch. I get the following error:

INFO -- : Writing /my_app/public/assets/tinymce/langs/ar-69ae416a591d8dfedb028bf7bb65a09a.js
INFO -- : Writing /my_app/public/assets/tinymce/langs/az-85782c946701af9ec2c26d3f5edcfa0d.js
INFO -- : Writing /my_app/public/assets/tinymce/langs/be-f92121959924c2c88beb8fc3e40c6186.js
... (removed some log lines)
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/ar.js
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/ar.js.gz
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/az.js
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/az.js.gz
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/be.js
INFO -- : Creating symlink /my_app/public/assets/tinymce/langs/be.js.gz
... (removed some log lines)
INFO -- : Removing digest from /my_app/public/assets/tinymce/langs/ar-69ae416a591d8dfedb028bf7bb65a09a.js
rake aborted!
ArgumentError: same file: /my_app/public/assets/tinymce/langs/ar-69ae416a591d8dfedb028bf7bb65a09a.js and /my_app/public/assets/tinymce/langs/ar.js
/my_app/bundler/gems/tinymce-rails-0b57091e0acb/lib/tinymce/rails/asset_installer/copy.rb:42:in `block in move_asset'
/my_app/bundler/gems/tinymce-rails-0b57091e0acb/lib/tinymce/rails/asset_installer.rb:58:in `with_asset'
/my_app/bundler/gems/tinymce-rails-0b57091e0acb/lib/tinymce/rails/asset_installer/copy.rb:5:in `with_asset'

By executing the following command:

$ RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile"

The gem version 4.1.6 has the same problem! Any idea?