Havvy
Havvy

Reputation: 1511

Import Phoenix Socket, Phoenix HTML JS Modules via Brunch when web server application is in an umbrella app

When a Phoenix web server is not in an umbrella app, Brunch finds the modules in "deps/phoenix/web/static/js/socket" and "deps/phoenix_html/web/static/js/phoenix_html" because the phoenix dependency gets installed into that location relative to the brunch config file.

When in an Umbrella app, the dependencies get installed in the umbrella app itself, not the web server app. So they are at "../../deps/phoenix/web/static/js/" instead.

I tried adding "../.." to the locations in the brunch config file and the import statements, and I cannot get Brunch to actually find the files.

Upvotes: 5

Views: 897

Answers (1)

José Valim
José Valim

Reputation: 51349

You need to configure the brunch config to point to the proper directory:

watched: ["../../deps/phoenix/web/static",
          "../../deps/phoenix_html/web/static",
          "web/static", "test/static"],

And then import:

import "../../../deps/phoenix_html/web/static/js/phoenix_html"

We should fix Phoenix though to generate such by default inside umbrellas.

Upvotes: 7

Related Questions