Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coingaming/phoenix_view_assets
https://github.com/coingaming/phoenix_view_assets
Last synced: about 15 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/coingaming/phoenix_view_assets
- Owner: coingaming
- Created: 2019-04-03T05:22:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T03:45:47.000Z (3 months ago)
- Last Synced: 2024-11-13T16:52:52.548Z (7 days ago)
- Language: Elixir
- Size: 19.5 KB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PhoenixViewAssets
## Deprecated: use package instead.
Helps to manage view specific assets in phoenix project. Uses automatic code splitting to avoid over-fetching or downloading assets twice, if they are used in multiple views. Also supports phoenix live reload.
## Installation
Add `phoenix_view_assets` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:phoenix_view_assets, "~> 0.1"}
]
end
```Use (or merge) `example_assets` for `assets/` in your project.
## Setup
1. Create module `MyAppWeb.Assets`:
```elixir
defmodule MyAppWeb.Assets do
use PhoenixViewAssets
end
```2. Use `MyAppWeb.Assets` in your layout view to generate `scripts` and `styles` functions in compile time.
```elixir
defmodule MyAppWeb.LayoutView do
use MyAppWeb, :view
use MyAppWeb.Assets
end
```3. Use `styles` and `scripts` functions generated by `MyAppWeb.Assets` to add assets to your layout:
```html...
<%= for path <- styles(@conn) do %>
<% end %>...
<%= for path <- scripts(@conn) do %>
<% end %>```