Packages

Serve static files from memory in the Phoenix Framework. This extension compiles all of a project's static assets (e.g. Javascript, HTML, images, etc) into Erlang modules and loads them into the Erlang VM, with the purpose of serving them fast and without a dependency on a filesystem.

Current section

Files

Jump to
exstatic lib mix tasks exstatic.compile.ex
Raw

lib/mix/tasks/exstatic.compile.ex

defmodule Mix.Tasks.Exstatic.Compile do
use Mix.Task
@default_input_path "priv/static"
@shortdoc "Compiles static files into Erlang code"
@moduledoc """
"""
def run(args) do
input_path = List.first(args) || @default_input_path
case ExStatic.Compiler.compile_all(input_path) do
{:ok, count} ->
Mix.shell.info "Compiled #{count} static files in #{input_path} to bytecode"
:ok
{:error, :invalid_path} ->
Mix.raise "Invalid static path: #{input_path}"
end
end
end