I was interested in testing out the WebSockets extension with a custom server but it seems that MakeCode only allows WebSocket connections to pass through on a github pages build. This means that testing any minor change requires me to push to repo, make a release and wait for the pages to build, and it makes debugging nearly impossible. Does anyone know if there’s a way to go around this during development? Maybe a way to build makecode locally while allowing for websocket connections? @richard
3 Likes
yeah, you can use the makecode cli! to install:
npm install -g makecode
then clone the repo locally:
git clone https://github.com/pelikhan/pxt-sockets.git
cd pxt-sockets
makecode install
and to serve locally:
makecode serve --force-local
the websocket magic is happening inside the assets/js/custom.js and assets/js/loader.js files, those are the custom js files that are being loaded into the simulator page. the --force-local flag here forces the server to use the local loader.js instead of the one that ships with the CLI
8 Likes
Thanks! You have no idea how much time you just saved me lol
2 Likes