-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a reference to consuming projects Endpoint module to generate dig…
…ested asset paths in production.
- Loading branch information
Showing
4 changed files
with
24 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,11 +50,13 @@ import topbar from 'topbar'; | |
|
||
You'll also need to replace the contents of `assets/vendor/topbar.js` with a wrapped version that supports ESM, like this [from jsDelivr](https://cdn.jsdelivr.net/npm/[email protected]/topbar.js/+esm). | ||
|
||
In `lib/<project>/components/layouts/root.html.heex` replace the `app.js` `<script>` tag with: | ||
In `lib/<project>/components/layouts/root.html.heex` replace the `app.js` `<script>` tag. | ||
|
||
Be sure to use your own project's module name in place of `YourAppWeb`. | ||
|
||
```html | ||
<script type="importmap"> | ||
<%= raw PhoenixImportmap.importmap() %> | ||
<%= raw PhoenixImportmap.importmap(YourAppWeb.Endpoint) %> | ||
</script> | ||
<script type="module"> | ||
import 'app'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,14 +48,16 @@ defmodule PhoenixImportmap do | |
You'll also need to replace the contents of `assets/vendor/topbar.js` with a wrapped version that supports ESM, like this [from jsDelivr](https://cdn.jsdelivr.net/npm/[email protected]/topbar.js/+esm). | ||
In `lib/<project>/components/layouts/root.html.heex` replace the `app.js` `<script>` tag with: | ||
In `lib/<project>/components/layouts/root.html.heex` replace the `app.js` `<script>` tag. | ||
Be sure to use your own project's module name in place of `YourAppWeb`. | ||
```html | ||
<script type="importmap"> | ||
<%= raw PhoenixImportmap.importmap() %> | ||
<%= raw PhoenixImportmap.importmap(YourAppWeb.Endpoint) %> | ||
</script> | ||
<script type="module"> | ||
import "app"; | ||
import 'app'; | ||
</script> | ||
``` | ||
|
@@ -87,11 +89,11 @@ defmodule PhoenixImportmap do | |
@doc """ | ||
Returns a JSON-formatted importmap based on your application configuration. | ||
Asset paths will have `:public_asset_path_prefix` stripped out. | ||
Requires `YourAppWeb.Endpoint` to be passed in for path generation. | ||
""" | ||
def importmap() do | ||
def importmap(endpoint) do | ||
application_importmap() | ||
|> Importmap.prepare() | ||
|> Importmap.prepare(endpoint) | ||
|> Importmap.json() | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters