From ba4273539272af5dda44e1a7ef82626bd2493086 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Fri, 20 Sep 2024 17:04:32 -0400 Subject: [PATCH 1/3] change es2017 to es2022 in asset management guide --- guides/asset_management.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/asset_management.md b/guides/asset_management.md index b789ee1774..baf917eeba 100644 --- a/guides/asset_management.md +++ b/guides/asset_management.md @@ -67,7 +67,7 @@ error: Could not resolve "/images/bg.png" (mark it as external to exclude it fro Given the images are already managed by Phoenix, you need to mark all resources from `/images` (and also `/fonts`) as external, as the error message says. This is what Phoenix does by default for new apps since v1.6.1+. In your `config/config.exs`, you will find: ```elixir -args: ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), +args: ~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), ``` If you need to reference other directories, you need to update the arguments above accordingly. Note running `mix phx.digest` will create digested files for all of the assets in `priv/static`, so your images and fonts are still cache-busted. @@ -114,7 +114,7 @@ let opts = { entryPoints: ["js/app.js"], bundle: true, logLevel: "info", - target: "es2017", + target: "es2022", outdir: "../priv/static/assets", external: ["*.css", "fonts/*", "images/*"], nodePaths: ["../deps"], From 22d9b5772d9e11ed5ced49c288e740c6a5e1a729 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sat, 21 Sep 2024 12:28:46 -0400 Subject: [PATCH 2/3] Update config.exs --- .../templates/phx_umbrella/apps/app_name_web/config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs b/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs index 2b2f6300d0..875dfc989d 100644 --- a/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs +++ b/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs @@ -22,7 +22,7 @@ config :esbuild, version: "0.17.11", <%= @web_app_name %>: [ args: - ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), + ~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), cd: Path.expand("../apps/<%= @web_app_name %>/assets", __DIR__), env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} ]<% end %><%= if @css do %> From 75f0a991bb191375cf10ffc4d177a1c465cb5edd Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Sat, 21 Sep 2024 12:29:17 -0400 Subject: [PATCH 3/3] Update config.exs --- installer/templates/phx_single/config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/templates/phx_single/config/config.exs b/installer/templates/phx_single/config/config.exs index 661291d54a..56f501d774 100644 --- a/installer/templates/phx_single/config/config.exs +++ b/installer/templates/phx_single/config/config.exs @@ -38,7 +38,7 @@ config :esbuild, version: "0.17.11", <%= @app_name %>: [ args: - ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), + ~w(js/app.js --bundle --target=es2022 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*), cd: Path.expand("..<%= if @in_umbrella, do: "/apps/#{@app_name}" %>/assets", __DIR__), env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} ]<% end %><%= if @css do %>