Phoenix 1.4 issue while working through FWD with Elixir, OTP and Phoenix

Arriving at chapter 7 we enter the world of websockets to test out a game channel. The author seems to be working with Phoenix 1.3.X with its build tool set to brunch. At the time of this writing Phoenix 1.4.X ships with webpack instead. At page 160 ‘Establish a Client Connection’ the author displays a snippet from within a browser’s console;

> var phoenix = require("phoenix")
undefined

This doesn’t work as variables ‘phoenix’, nor ‘require’ seem to be globally exposed by webpack. What’s the proper webpack configuration or console snippet update to continue the tutorial as-is? If someone already worked through this book with Phoenix 1.4+ it would be nice to have a reference somewhere on this forum. Meanwhile I’ll try my luck poking around the webpack config. Stay tuned.

I show a little hack… for the same book, same problem.

2 Likes