msw10100

msw10100

I have an umbrella app with an existing Phoenix app inside. I want to add another phoenix app, listening on a different port.

I ran mix phx.new.web internal_ui --no-ecto --no-mailer from the apps folder of my umbrella to generate the app. All looked good. I changed the port to 4001 for the new app.

However, I noticed that when I built and ran my application, my assets for the new app did not get built. No app.js. No app.css. No minified or gzipped files.

Looking deeper, I see that there are two config :esbuild entries in the config.exs, and the one for the new app is first. Won’t the configuration for the second overwrite the first? When I move the esbuild config for the new app below the one for the original web app, my app.js does get built in the priv/static of my new app, but no CSS files get built.

How can I get my priv/static files to build for multiple Phoenix apps?

Showing Posts 1 to 2

msw10100

msw10100 OP

Okay, I’ve got this one figured out after reading this StackOverflow post. It’d be awesome if the phx.new.web generator could figure this one out, or perhaps detect the condition and give the developer a clue as to how to proceed.

The generated esbuild and tailwind configs both have a default profile. The new web app requires a different profile under the existing config :esbuild and config :tailwind keys, with a name other than default.

For example:

config :tailwind,
  version: "3.3.2",
  default: [
    args: ~w(
      --config=tailwind.config.js
      --input=css/app.css
      --output=../priv/static/assets/app.css
    ),
    cd: Path.expand("../apps/job_web/assets", __DIR__)
  ],
  internal_ui: [
    args: ~w(
      --config=tailwind.config.js
      --input=css/app.css
      --output=../priv/static/assets/app.css
    ),
    cd: Path.expand("../apps/internal_ui/assets", __DIR__)
  ]

and

config :esbuild,
  version: "0.17.11",
  default: [
    args:
      ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
    cd: Path.expand("../apps/job_web/assets", __DIR__),
    env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
  ],
  internal_ui: [
    args:
      ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
    cd: Path.expand("../apps/internal_ui/assets", __DIR__),
    env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
  ]

Then, back in the dev.exs config, you have to edit the generated watchers key, replacing default with the key you specified in the tailwind and esbuild configs for the new profile.

If anyone knows of anything else that needs to be done, please reply with additions.

Cheers!

msw10100

msw10100 OP

[deleted]

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews