Copying javascript files to destination assets directory (almost) without assets pipeline

In my project I am using ckeditor as default HTML editor. One of the
strongest feature of ckeditor is that all its components are loaded from
server when started and can thus be easily extended. Which is also a
nightmare for rails developers because this problem cannot be solved by
assets pipeline especially if used as gem.

In ckeditor gem, which can be found on github
GitHub - galetahub/ckeditor: Ckeditor 4.x integration gem for rails the problem was solved by adding
every single required file to app.config.assets.precompile which made
(in my case) assets compilation go from 1 minute to >5 minutes. What is
not acceptable.

Not until recently I found out assets:precompile rake task (why is this
so poor mentioned in documentation). Which can be added to every gem and
it is executed once when rake assets:precompile is invoked. So here is
my solution now:

(file lib/tasks/copy_assets.rb)
require ‘fileutils’

desc “Copy all ckeditor files from gem’s javascript folder to
public/assets/folder”
task “assets:precompile” do
p ‘Copying ckeditor directory to public/assets folder *****’

input_dir = File.realpath( File.dirname( FILE ) +
‘/…/…/app/assets/javascripts/ckeditor’)
output_dir = Rails.root.join(‘public/assets’)
cp_r(input_dir, output_dir, verbose: true)
end

It works perfectly for me. I feel very stupid copying files for last two
years by hand. Is there any problem to be expected except the usual ones
with browser caching?

by
TheR