Add path_resolver parameter to font generation functions so both font preloads and CSS @font-face declarations use the same digested paths in production. This prevents duplicate font downloads when preloads were using digested paths but CSS used non-digested paths. - Add path_resolver parameter to Fonts.generate_font_faces/2, Fonts.preload_links/2, and Fonts.generate_all_font_faces/1 - Update CSSGenerator.generate/2 to accept path_resolver - Update CSSCache.warm/0 to use Endpoint.static_path/1 - Move CSSCache to start after Endpoint in supervision tree - Add 1-year cache headers for static assets Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
46 lines
1.5 KiB
Elixir
46 lines
1.5 KiB
Elixir
defmodule SimpleshopTheme.Application do
|
|
# See https://hexdocs.pm/elixir/Application.html
|
|
# for more information on OTP Applications
|
|
@moduledoc false
|
|
|
|
use Application
|
|
|
|
@impl true
|
|
def start(_type, _args) do
|
|
children = [
|
|
SimpleshopThemeWeb.Telemetry,
|
|
SimpleshopTheme.Repo,
|
|
{Ecto.Migrator,
|
|
repos: Application.fetch_env!(:simpleshop_theme, :ecto_repos), skip: skip_migrations?()},
|
|
{DNSCluster, query: Application.get_env(:simpleshop_theme, :dns_cluster_query) || :ignore},
|
|
{Phoenix.PubSub, name: SimpleshopTheme.PubSub},
|
|
# Background job processing
|
|
{Oban, Application.fetch_env!(:simpleshop_theme, Oban)},
|
|
# Image variant cache - ensures all variants exist on startup
|
|
SimpleshopTheme.Images.VariantCache,
|
|
# Start to serve requests
|
|
SimpleshopThemeWeb.Endpoint,
|
|
# Theme CSS cache - must start after Endpoint for static_path/1 to work
|
|
SimpleshopTheme.Theme.CSSCache
|
|
]
|
|
|
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
|
# for other strategies and supported options
|
|
opts = [strategy: :one_for_one, name: SimpleshopTheme.Supervisor]
|
|
Supervisor.start_link(children, opts)
|
|
end
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
# whenever the application is updated.
|
|
@impl true
|
|
def config_change(changed, _new, removed) do
|
|
SimpleshopThemeWeb.Endpoint.config_change(changed, removed)
|
|
:ok
|
|
end
|
|
|
|
defp skip_migrations?() do
|
|
# By default, sqlite migrations are run when using a release
|
|
System.get_env("RELEASE_NAME") == nil
|
|
end
|
|
end
|