module Lune::Assets

Defined in:

lune/assets.cr

Constant Summary

MIME_TYPES = {".html" => "text/html; charset=utf-8", ".js" => "application/javascript", ".mjs" => "application/javascript", ".css" => "text/css", ".json" => "application/json", ".png" => "image/png", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".gif" => "image/gif", ".svg" => "image/svg+xml", ".ico" => "image/x-icon", ".woff" => "font/woff", ".woff2" => "font/woff2", ".ttf" => "font/ttf", ".eot" => "application/vnd.ms-fontobject", ".webp" => "image/webp", ".map" => "application/json"}

Class Method Summary

Macro Summary

Class Method Detail

def self.empty? : Bool #

[View source]
def self.get(path : String) : Bytes | Nil #

[View source]
def self.mime_for(path : String) : String #

[View source]
def self.register(path : String, content : Bytes) #

[View source]

Macro Detail

macro embed_dir(dir) #

Embeds all files under dir at compile time into the binary. Call this at the top level of your app file, not inside a method. The path is relative to the file where the macro is called.

Lune::Assets.embed_dir("frontend/dist")

Files are registered as "/" e.g. "/index.html", "/assets/main.js".


[View source]