diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 2b1e454fa..06909310e 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -19,16 +19,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 000000000..16c775241 --- /dev/null +++ b/lib/tasks/assets.rake @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +namespace :assets do + desc 'Copy Bootstrap glyphicons and TinyMCE skins to the public directory' + task :copy_assets 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 + + # Set assets:copy_assets as an extension of assets:precompile + Rake::Task['assets:precompile'].enhance do + Rake::Task['assets:copy_assets'].invoke + end +end