Installation Guide
This guide will walk you through the installation process step by step.
1. Add Hologram Package
Add the Hologram package to your dependencies list in mix.exs
:
{:hologram, "~> 0.2"},
2. Fetch Dependencies
Run the following command to fetch the Hologram package:
$ mix deps.get
3. Configure Compiler
Add the Hologram compiler to your project configuration in mix.exs
:
def project do
[
# ...
compilers: Mix.compilers() ++ [:hologram],
# ...
]
end
4. Configure Endpoint
Update your application's endpoint module to use Hologram:
defmodule MyAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :my_app
use Hologram.Endpoint
# ...
end
5. Setup Hologram Socket
Add the Hologram socket to your endpoint configuration:
defmodule MyAppWeb.Endpoint do
# ...
hologram_socket()
# ...
end
6. Configure Router
Add the Hologram router plug before your Phoenix router plug in your endpoint:
defmodule MyAppWeb.Endpoint do
# ...
plug Hologram.Router
plug MyAppWeb.Router
end
7. Configure Static Asset Serving
Add the Hologram directory to the list of served static directories in your endpoint:
plug Plug.Static,
# ...
only: ["hologram" | MyAppWeb.static_paths()]
8. Configure Formatter
Import Hologram formatter rules in .formatter.exs
:
[
# ...
import_deps: [..., :hologram]
# ...
]
9. Update GitIgnore
Add the following line to your .gitignore
file to exclude Hologram generated JavaScript bundles:
# Hologram generated JavaScript bundles.
/priv/static/hologram/
Next Steps
After completing the installation, you can start building your isomorphic web application with Hologram. For more information on how to use Hologram's features, please refer to the website's Documentation section.
Notes
- Make sure all dependencies are properly installed and configured
- Verify that your Phoenix application is properly set up before installing Hologram