You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
703 B

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