assets.rake 630 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. def render_static_page(action, dest:, **opts)
  3. I18n.with_locale(ENV['DEFAULT_LOCALE'] || I18n.default_locale) do
  4. html = ApplicationController.render(action, opts)
  5. File.write(dest, html)
  6. end
  7. end
  8. namespace :assets do
  9. desc 'Generate static pages'
  10. task :generate_static_pages do
  11. render_static_page 'errors/500', layout: 'error', dest: Rails.root.join('public', 'assets', '500.html')
  12. end
  13. end
  14. if Rake::Task.task_defined?('assets:precompile')
  15. Rake::Task['assets:precompile'].enhance do
  16. Webpacker.manifest.refresh
  17. Rake::Task['assets:generate_static_pages'].invoke
  18. end
  19. end