hyperstack-org / hyperstack-org/hyperstack

Hotloader needs special treatment for gitpod

未關閉
#202 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Gitpod integration
主要語言
JavaScript
星號
538
分支
41
PR 合併指標
30 天內沒有已合併 PR

描述

This works:

```ruby
module Hyperstack
class Hotloader
def connect_to_websocket(port)
if `window.location.host` =~ /\d+-([a-f0-9\-]+\..+\.gitpod.io)/
ws_url = "#{port}-#{$1}"
else
host = `window.location.host`.sub(/:\d+/, '')
host = '127.0.0.1' if host == ''
ws_url = "#{host}"
end
puts "Hot-Reloader connecting to #{ws_url}"
protocol = `window.location.protocol` == 'https:' ? 'wss:' : 'ws:'
ws = `new WebSocket(#{protocol} + '//' + #{ws_url})`
`#{ws}.onmessage = #{lambda { |e| reload(e) }}`
`setInterval(function() { #{ws}.send('') }, 10000)` if @ping
end
end
end
```
maybe put the gitpod on some configuration switch

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。