fix(web): committed dist/.gitkeep keeps go:embed satisfiable pre-build

This commit is contained in:
weichen
2026-09-24 16:20:21 +00:00
parent cc90d39205
commit 6cbe7e6e56
3 changed files with 4 additions and 11 deletions
+1
View File
@@ -0,0 +1 @@
Keeps //go:embed all:dist satisfiable before first npm run build.
-2
View File
@@ -1,2 +0,0 @@
Placeholder so //go:embed all:dist stays satisfiable before the first
`npm run build` materializes web/dist (gitignored). Never served.
+3 -9
View File
@@ -7,19 +7,13 @@ import (
// DistFS holds the production SPA build (npm run build + precompress). // DistFS holds the production SPA build (npm run build + precompress).
// Build scripts must materialize web/dist before `go build`; the directory is // Build scripts must materialize web/dist before `go build`; the directory is
// gitignored. When dist is absent (fresh checkout / CI vet), the file-target // gitignored except dist/.gitkeep, which keeps the pattern satisfiable on
// pattern below embeds nothing and LookupDist returns false so callers fall // fresh checkouts. LookupDist returns false until a real build lands, so
// back to disk-only mode. // callers fall back to disk-only mode.
// //
//go:embed all:dist //go:embed all:dist
var DistFS embed.FS var DistFS embed.FS
// distPlaceholder keeps the embed pattern satisfiable on fresh checkouts
// where web/dist has never been built.
//
//go:embed dist_placeholder
var distPlaceholder []byte
// LookupDist returns the embedded dist subtree when the build populated it. // LookupDist returns the embedded dist subtree when the build populated it.
func LookupDist() (fs.FS, bool) { func LookupDist() (fs.FS, bool) {
sub, err := fs.Sub(DistFS, "dist") sub, err := fs.Sub(DistFS, "dist")