Add
SERVE_STATIC_ASSETS="true"
to.env.development
and.env.test
in order to serve static assets locally.Add
require 'hanami/rake_tasks'
toRakefile
in order to enable:preload
and:environment
Rake tasksRename
default_format
intodefault_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
intoapps/web/assets
as assets sourcesAdd
require 'hanami/assets'
at the top ofapps/web/application.rb
Add
include Web::Assets::Helpers
intoview.prepare
block ofapps/web/application.rb
Change assets configuration into
apps/web/application.rb
from:assets << [
# 'vendor/javascripts'
]
to:
assets do
javascript_compressor :builtin
stylesheet_compressor :builtin
sources << [
'assets',
# 'vendor/assets'
]
end
Add the following code inside the
configure :production
block ofapps/web/application.rb
assets do
compile false
digest true
# CDN Mode (optional)
# scheme 'https'
# host '123.cloudfront.net'
# port 443
end
If you have any problem, don’t hesitate to look for help in chat.