Create Phoenix umbrella in existing umbrella?

I have an existing umbrella app, let’s say foo_umbrella. I want to create a new Phoenix umbrella, but under that existing umbrella. Here is what I tried:

mix phx.new bar --umbrella --no-ecto --no-gettext --live
mv bar_umbrella/apps/bar_web/ foo_umbrella/apps/
mv bar_umbrella/apps/bar/ foo_umbrella/apps/
mv bar_umbrella/config foo_umbrella/apps/bar_web

That almost works, but assets won’t compile because it’s getting some paths wrong:

[error] Could not start node watcher because script
"/Users/christopher.bottaro/Work/multiverse/foo_umbrella/apps/bar_web/apps/bar_web/assets/node_modules/webpack/bin/webpack.js"
does not exist. Your Phoenix application is still running, however assets won't be compiled. You may fix this by running "npm install" inside the "assets" directory.

Is there a better way to do this? Thanks for the help!

There are also mix phx.new.ecto and mix phx.new.web tasks for exactly this scenario, as part of the phx_new package.

2 Likes

To solve the error stated in the OP, you need to go into your config/dev.exs file and update the following line with the correct path of your assets directory:

config :admin, AdminWeb.Endpoint,
  http: [port: 4000],
  debug_errors: true,
  code_reloader: true,
  check_origin: false,
  watchers: [
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch-stdin",
      cd: Path.expand("../assets", __DIR__) # Change the string in this line (in my case to "../apps/admin/assets")
    ]
  ]