diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ed78d115f4..bd4c6cb22a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -14,16 +14,3 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) - -# Bootstrap and TinyMCE expect their files to live in a specific place, so copy them over -puts "Copying Bootstrap glyphicons to the public directory ..." -source_dir = Dir.glob(Rails.root.join('node_modules', 'bootstrap', 'fonts', 'glyphicons-halflings-regular.*')) -destination_dir = Rails.root.join('public', 'fonts', 'bootstrap') -FileUtils.mkdir_p(destination_dir) -FileUtils.cp_r(source_dir, destination_dir) - -puts "Copying TinyMCE skins to the public directory ..." -source_dir = Dir.glob(Rails.root.join('node_modules', 'tinymce', 'skins', 'ui', 'oxide')) -destination_dir = Rails.root.join('public', 'tinymce', 'skins') -FileUtils.mkdir_p(destination_dir) -FileUtils.cp_r(source_dir, destination_dir) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake new file mode 100644 index 0000000000..8d612920fa --- /dev/null +++ b/lib/tasks/assets.rake @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +namespace :assets do + desc 'Copy Bootstrap glyphicons and TinyMCE skins to the public directory' + task :copy do + # Bootstrap and TinyMCE expect their files to live in a specific place, so copy them over + puts 'Copying Bootstrap glyphicons to the public directory ...' + source_dir = Dir.glob(Rails.root.join('node_modules', 'bootstrap', 'fonts', 'glyphicons-halflings-regular.*')) + destination_dir = Rails.root.join('public', 'fonts', 'bootstrap') + FileUtils.mkdir_p(destination_dir) + FileUtils.cp_r(source_dir, destination_dir) + + puts 'Copying TinyMCE skins to the public directory ...' + source_dir = Dir.glob(Rails.root.join('node_modules', 'tinymce', 'skins', 'ui', 'oxide')) + destination_dir = Rails.root.join('public', 'tinymce', 'skins') + FileUtils.mkdir_p(destination_dir) + FileUtils.cp_r(source_dir, destination_dir) + end + + # Run the copy task before precompiling assets + task precompile: :copy +end