Skip to content

Commit

Permalink
do not deliver observability UI if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
d-led committed Jul 17, 2024
1 parent d9fb326 commit b107d40
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions transpile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ import (
)

func Refresh() {
log.Println("transpiling & copying")
log.Printf("transpiling & copying: %v, %v", staticFilesToCopy(), esbuildEntrypoints())
transpile()
copyStatic()
}

func copyStatic() {
for _, f := range []string{
"index.html",
"cluster.html",
"index.css",
} {
for _, f := range staticFilesToCopy() {
text, err := os.ReadFile(filepath.Join(uiSrc, f))
crashOnError(err)
os.WriteFile(filepath.Join(dist, f), text, 0644)
Expand All @@ -28,14 +24,12 @@ func copyStatic() {

func transpile() {
result := api.Build(api.BuildOptions{
EntryPoints: []string{
filepath.Join(uiSrc, "index.ts"),
filepath.Join(uiSrc, "cluster.ts"),
},
Bundle: true,
Outdir: dist,
MinifySyntax: false,
MinifyWhitespace: false,
EntryPoints: esbuildEntrypoints(),
Bundle: true,
Outdir: dist,
MinifySyntax: false,
MinifyWhitespace: false,

MinifyIdentifiers: false,
Sourcemap: api.SourceMapInline,
Engines: []api.Engine{
Expand All @@ -48,3 +42,24 @@ func transpile() {
})
handleErrors(result.Errors)
}

func staticFilesToCopy() []string {
var res = []string{
"index.html",
"index.css",
}
if ClusterObservabilityEnabled {
res = append(res, "cluster.html")
}
return res
}

func esbuildEntrypoints() []string {
var res = []string{
filepath.Join(uiSrc, "index.ts"),
}
if ClusterObservabilityEnabled {
res = append(res, filepath.Join(uiSrc, "cluster.ts"))
}
return res
}

0 comments on commit b107d40

Please sign in to comment.