`npm run sync` in web/ copies the build output (web/dist, from npm run build) to internal/frontend/dist, which the binary embeds. Go can't embed from outside the package's directory (web/ is also outside the Go module), hence the copy. Only dist/.gitkeep is committed, so a fresh clone still compiles, and a binary built without syncing first serves no frontend. job-search serve serves server.frontend.dir if it is set, or else the embedded build, or warns that there is no frontend. scripts/build.sh builds and syncs the frontend before building, running npm ci first for a release or when web/node_modules is missing.
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
// JSCKServerFrontend is the frontend section's configuration key.
|
|
const JSCKServerFrontend string = "frontend"
|
|
|
|
// JSCServerFrontend configures how the server serves the frontend. Dir is
|
|
// the directory of the frontend's build output (holding index.html); empty
|
|
// means the build embedded in the binary, or no frontend if it has none.
|
|
// ImmutablePrefix is where Vite emits content-hashed files, cached for a
|
|
// year; empty means "/assets/". IndexCacheControl is the Cache-Control of
|
|
// HTML and other files without a hash; empty means "no-cache".
|
|
type JSCServerFrontend struct {
|
|
Dir string `cfg:"dir"`
|
|
ImmutablePrefix string `cfg:"immutable_prefix"`
|
|
IndexCacheControl string `cfg:"index_cache_control"`
|
|
}
|
|
|
|
// ---------- Section methods (see Section) ----------
|
|
|
|
// Map implements Section.
|
|
func (c JSCServerFrontend) Map() map[string]any { return mapOf(c) }
|
|
|
|
// Flatten implements Section.
|
|
func (c JSCServerFrontend) Flatten() map[string]any {
|
|
return flattenOf(JSCKServerFrontend, c)
|
|
}
|
|
|
|
// TypeOf implements Section.
|
|
func (c JSCServerFrontend) TypeOf(key string) (reflect.Kind, error) {
|
|
return typeOf(c, key)
|
|
}
|
|
|
|
// ValueOf implements Section.
|
|
func (c JSCServerFrontend) ValueOf(key string) (any, error) {
|
|
return valueOf(c, key)
|
|
}
|
|
|
|
// SetValue implements Section.
|
|
func (c *JSCServerFrontend) SetValue(key string, value any) error {
|
|
return setValue(c, key, value)
|
|
}
|