Skip to content

Commit

Permalink
Switch lofimusic app to use gopherjs instead of wasm.
Browse files Browse the repository at this point in the history
This commit contains all manual changes that are required to make the
app work with gopherjs. (Spoiler: it's not a lot!)
  • Loading branch information
nevkontakte committed May 6, 2023
1 parent 5f22f86 commit b7a59ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions bin/lofimusic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ type githubOptions struct {
Output string `cli:"o" env:"-" help:"The directory where static resources are saved."`
}

type gopherJSDriver struct{}

func (d *gopherJSDriver) Scripts() []string { return nil }
func (d *gopherJSDriver) Styles() []string { return nil }
func (d *gopherJSDriver) CacheableResources() []string { return nil }
func (d *gopherJSDriver) PreRenderItems() []app.PreRenderedItem { return nil }

func main() {
for _, l := range getLiveRadios() {
app.Route("/"+l.Slug, newRadio())
Expand Down Expand Up @@ -91,9 +98,11 @@ func main() {
"https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500&display=swap",
"/web/lofimusic.css",
},
Scripts: []string{"/web/app.js"},

ThemeColor: backgroundColor,
Title: "Lofimusic",
Driver: &gopherJSDriver{},
}

opts := options{Port: 4000}
Expand Down
10 changes: 7 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
build:
@GOARCH=wasm GOOS=js go build -o docs/web/app.wasm ./bin/lofimusic
tools:
go install -v github.com/gopherjs/[email protected]

build: tools
@gopherjs build -o docs/web/app.js ./bin/lofimusic
@go build -o docs/lofimusic ./bin/lofimusic

run: build
@cd docs && ./lofimusic local


build-github: build
ls -l docs/web/app.js
@cd docs && ./lofimusic github

github: build-github clean

test:
go test ./bin/lofimusic
GOARCH=wasm GOOS=js go test ./bin/lofimusic
gopherjs test ./bin/lofimusic

clean:
@go clean ./...
Expand Down

0 comments on commit b7a59ae

Please sign in to comment.