File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
apps/components_guide_web/lib Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ defmodule ComponentsGuideWeb.Endpoint do
1313 )
1414
1515 socket ( "/live" , Phoenix.LiveView.Socket , websocket: [ connect_info: [ session: @ session_options ] ] )
16+
17+ plug ( Plug.Static ,
18+ at: "/collected/image" ,
19+ from: { :components_guide_web , "priv/static/collected/image" } ,
20+ gzip: false ,
21+ only: ~w( svg png jpg gif)
22+ )
1623
1724 # Serve at "/" the static files from "priv/static" directory.
1825 #
@@ -22,14 +29,7 @@ defmodule ComponentsGuideWeb.Endpoint do
2229 at: "/" ,
2330 from: :components_guide_web ,
2431 gzip: false ,
25- only: ~w( css fonts images js favicon.ico robots.txt collected)
26- )
27-
28- plug ( Plug.Static ,
29- at: "/collected/image" ,
30- from: { :components_guide_web , "priv/static/collected/image" } ,
31- gzip: false ,
32- only: ~w( svg png jpg gif)
32+ only: ~w( css fonts images js favicon.ico robots.txt)
3333 )
3434
3535 # Code reloading can be explicitly enabled under the
Original file line number Diff line number Diff line change @@ -29,11 +29,14 @@ defmodule Mix.Tasks.TemplateAssets do
2929 media_type = MIME . from_path ( image_path )
3030 hash = :crypto . hash ( :sha256 , data )
3131 hash_base64 = hash |> Base . url_encode64 ( )
32+
3233 destination_dir = Path . join ( static_collected_dir ( ) , media_type )
3334 File . mkdir_p! ( destination_dir )
35+
3436 extension = MIME . extensions ( media_type ) |> List . first ( )
3537 destination_path = Path . join ( destination_dir , "#{ hash_base64 } .#{ extension } " )
3638 File . copy! ( image_path , destination_path )
39+
3740 Mix . shell ( ) . info ( "Copied #{ image_path } to #{ destination_path } " )
3841 end
3942end
You can’t perform that action at this time.
0 commit comments