Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 831
Havvy Avatar asked Aug 31 '15 04:08

Havvy


People also ask

Does phoenix phoenix ship with a JavaScript implementation?

Phoenix ships with a JavaScript implementation of both websocket and long polling that interacts with Phoenix.Socket and can be used as reference for those interested in implementing custom clients.

What is a socket in Phoenix?

A socket implementation that multiplexes messages over channels. Phoenix.Socket is used as a module for establishing and maintaining the socket state via the Phoenix.Socket struct. Once connected to a socket, incoming and outgoing events are routed to channels.

What are the helpers in Phoenix for HTML?

Helpers for working with HTML strings and templates. When used, it imports the given modules: Phoenix.HTML - functions to handle HTML safety; Phoenix.HTML.Tag - functions for generating HTML tags;

What are the functions of Phoenix HTML?

Phoenix.HTML.Link - functions for generating links and urls; Phoenix.HTML.Format - functions for formatting text; One of the main responsibilities of this module is to provide convenience functions for escaping and marking HTML code as safe.


1 Answers

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.

like image 180
José Valim Avatar answered Oct 03 '22 23:10

José Valim