Phoenix and Windows: js not executed
I’m currently on my way to learn a little bit of Elixir. I like the idea of functional programming language made easy. For starters I’m doing all the tutorials I can find. My most recent tutorial was the Channels Tutorial of the Phoenix Framework.
As I did the tutorial, I encountered a problem: My socket.js file was concatenated in the app.js file via Brunch.io but the promised message “Joined successfully” did not show up in the console.
After some fiddling with JavaScript I gave up and searched for the error. I found a similar error description on Stack “js in html is not executing in Phoenix framework sample app”. As it turns out the tutorial/the getting started is not really covering the Windows side… To fix this problem edit your /brunch-config.js file.
At the bottom is a modules key. Change the value from
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"]
}
}
to
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"],
"js\\app.js": ["web/static/js/app"]
}
}
Voilà, brunch.io is now auto requiring the missing app.js even under Windows