Skip to content

Commit

Permalink
Use app names instead of "default" for configs (#5683)
Browse files Browse the repository at this point in the history
When adding more than one app to your umbrella project you can't use default
for tailwind and esbuild configurations or they will clash between them. By
using their names instead of "default" the issue is fixed.

To make the formatter happy the commands need to be splitted in several lines.

Closes #5631
  • Loading branch information
agonzalezro authored Dec 30, 2023
1 parent 5c768de commit 9f24517
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions installer/templates/phx_single/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ config :<%= @app_name %>, <%= @app_module %>.Mailer, adapter: Swoosh.Adapters.Lo
# Configure esbuild (the version is required)
config :esbuild,
version: "0.17.11",
default: [
<%= @app_name %>: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("..<%= if @in_umbrella, do: "/apps/#{@app_name}" %>/assets", __DIR__),
Expand All @@ -46,7 +46,7 @@ config :esbuild,
# Configure tailwind (the version is required)
config :tailwind,
version: "3.3.2",
default: [
<%= @app_name %>: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
Expand Down
4 changes: 2 additions & 2 deletions installer/templates/phx_single/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ config :<%= @app_name %>, <%= @endpoint_module %>,
debug_errors: true,
secret_key_base: "<%= @secret_key_base_dev %>",
watchers: <%= if @javascript or @css do %>[<%= if @javascript do %>
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}<%= if @css, do: "," %><% end %><%= if @css do %>
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}<% end %>
esbuild: {Esbuild, :install_and_run, [:<%= @app_name %>, ~w(--sourcemap=inline --watch)]}<%= if @css, do: "," %><% end %><%= if @css do %>
tailwind: {Tailwind, :install_and_run, [:<%= @app_name %>, ~w(--watch)]}<% end %>
]<% else %>[]<% end %>

# ## SSL Support
Expand Down
6 changes: 4 additions & 2 deletions installer/templates/phx_single/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ defmodule <%= @app_module %>.MixProject do
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"]<% end %><%= if @asset_builders != [] do %>,
"assets.setup": <%= inspect Enum.map(@asset_builders, &"#{&1}.install --if-missing") %>,
"assets.build": <%= inspect Enum.map(@asset_builders, &"#{&1} default") %>,
"assets.deploy": <%= inspect Enum.map(@asset_builders, &"#{&1} default --minify") ++ ["phx.digest"] %><% end %>
"assets.build": <%= inspect Enum.map(@asset_builders, &"#{&1} #{@app_name}") %>,
"assets.deploy": [
<%= Enum.map(@asset_builders, &" \"#{&1} #{@app_name} --minify\",\n") ++ [" \"phx.digest\""] %>
]<% end %>
]
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ config :<%= @web_app_name %>, <%= @endpoint_module %>,
# Configure esbuild (the version is required)
config :esbuild,
version: "0.17.11",
default: [
<%= @web_app_name %>: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../apps/<%= @web_app_name %>/assets", __DIR__),
Expand All @@ -30,7 +30,7 @@ config :esbuild,
# Configure tailwind (the version is required)
config :tailwind,
version: "3.3.2",
default: [
<%= @web_app_name %>: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ config :<%= @web_app_name %>, <%= @endpoint_module %>,
debug_errors: true,
secret_key_base: "<%= @secret_key_base_dev %>",
watchers: <%= if @javascript or @css do %>[<%= if @javascript do %>
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}<%= if @css, do: "," %><% end %><%= if @css do %>
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}<% end %>
esbuild: {Esbuild, :install_and_run, [:<%= @web_app_name %>, ~w(--sourcemap=inline --watch)]}<%= if @css, do: "," %><% end %><%= if @css do %>
tailwind: {Tailwind, :install_and_run, [:<%= @web_app_name %>, ~w(--watch)]}<% end %>
]<% else %>[]<% end %>

# ## SSL Support
Expand Down
6 changes: 4 additions & 2 deletions installer/templates/phx_umbrella/apps/app_name_web/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ defmodule <%= @web_namespace %>.MixProject do
setup: ["deps.get"<%= if @asset_builders != [] do %>, "assets.setup", "assets.build"<% end %>]<%= if @ecto do %>,
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"]<% end %><%= if @asset_builders != [] do %>,
"assets.setup": <%= inspect Enum.map(@asset_builders, &"#{&1}.install --if-missing") %>,
"assets.build": <%= inspect Enum.map(@asset_builders, &"#{&1} default") %>,
"assets.deploy": <%= inspect Enum.map(@asset_builders, &"#{&1} default --minify") ++ ["phx.digest"] %><% end %>
"assets.build": <%= inspect Enum.map(@asset_builders, &"#{&1} #{@web_app_name}") %>,
"assets.deploy": [
<%= Enum.map(@asset_builders, &" \"#{&1} #{@web_app_name} --minify\",\n") ++ [" \"phx.digest\""] %>
]<% end %>
]
end
end

0 comments on commit 9f24517

Please sign in to comment.