• Add SERVE_STATIC_ASSETS="true" to .env.development and .env.test in order to serve static assets locally.

    • Add require 'hanami/rake_tasks' to Rakefile in order to enable :preload and :environment Rake tasks

    • Rename default_format into default_request_format for all the applications (eg. apps/web/application.rb)

    • Delete all serve_assets occurrences from all the applications (eg. apps/web/application.rb)

    • Create public/ directory at the root of the project (if not already existing)

    • Add public/assets* to .gitignore

    • Rename apps/web/public into apps/web/assets as assets sources

    • Add require 'hanami/assets' at the top of apps/web/application.rb

    • Add include Web::Assets::Helpers into view.prepare block of apps/web/application.rb

    • Change assets configuration into apps/web/application.rb from:

      1. assets << [
      2. # 'vendor/javascripts'
      3. ]

      to:

      1. assets do
      2. javascript_compressor :builtin
      3. stylesheet_compressor :builtin
      4. sources << [
      5. 'assets',
      6. # 'vendor/assets'
      7. ]
      8. end
    • Add the following code inside the configure :production block of apps/web/application.rb

      1. assets do
      2. compile false
      3. digest true
      4. # CDN Mode (optional)
      5. # scheme 'https'
      6. # host '123.cloudfront.net'
      7. # port 443
      8. end

    If you have any problem, don’t hesitate to look for help in chat.