sodapopcan

sodapopcan

Access phoenix.js from Chrome devtools

I’m working through Function Web Development with Elixir, OTP, and Phoenix which is a really eye-opening, fantastic book.

Of course, it’s a little out of date. It was written when Brunch was still bundled with Phoenix but now we have Webpack, so when instructed to type var phoenix = require("phoenix") in dev tools, that just doesn’t work.

I’ve searched for importing webpacked modules in dev tools to no avail. Perhaps I’m just tired—I’ve been working at this for hours now—but is there a way to access phoenix.js in Chrome’s dev tools in 1.5?

Thanks!

Marked As Solved

dorgan

dorgan

To access something from the devtools, it needs to be globally accessible
One way of doing it is by assigning it to the window object, for example:

import phoenix from "phoenix";
window["phoenix"] = phoenix;

Then in the devtools you can now access it as phoenix. It should work regardless of the build tool you’re using.

Generally, importing a library with a script tag pointing to the file(like https://www.unpkg.com/phoenix@1.5.4/assets/js/phoenix.js) works too, but I don’t know if it does for phoenix too

Also Liked

lance

lance

Author of Functional Web Development with Elixir, OTP, and Phoenix

Hey @sodapopcan,

Welcome!

No worries about @'ing me. :slight_smile: I’m so glad you found the book useful. It’s always great to hear when your work has helped other folks!

I don’t have immediate plans for a second edition, though the thought has crossed my mind. Books are a big undertaking, and I would want to make sure I’ve got the spare cycles to complete the job before I took it on.

For now, let’s just say the idea is simmering rather than at a full boil. :slight_smile:

Cheers!

Last Post!

sodapopcan

sodapopcan

Thanks for the welcome and thanks for the response! (I have been offline for several days here)

Cheers :slight_smile:

Where Next?

Popular in Questions Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement