Forum: Ruby on Rails Copying javascript files to destination assets directory (almost) without assets pipeline

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2014-08-26 12:39
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
https://github.com/galetahub/ckeditor 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
This topic is locked and can not be replied to.