Files
cc-connect/web/embed.go
T
Claude 433e7d63fc refactor(web): embed frontend assets into binary via go:embed
Replace the npm-based install/upgrade workflow with compile-time
embedding. The web/dist/ directory is now embedded directly into the
binary using go:embed and registered through core's plugin registry
pattern (web/embed.go → core.RegisterWebAssets).

- Add web/embed.go (go:build !no_web) and web/embed_stub.go
- Add core/web_assets.go as the embedded FS registry
- Add cmd/cc-connect/plugin_web.go to import the web package
- Rewrite management.go static serving to use io/fs instead of disk
- Simplify /web command to setup + status (remove install/upgrade/uninstall)
- Clean up web_manager.go (remove npm logic, keep GenerateToken)
- Update Makefile with web build target and NO_WEB/build-noweb support
- Remove .npmignore and npm publishing fields from package.json

Binary size impact: ~1MB (16M → 17M). Use `no_web` tag to exclude.

Made-with: Cursor
2026-03-31 08:33:20 +08:00

22 lines
287 B
Go

//go:build !no_web
package web
import (
"embed"
"io/fs"
"github.com/chenhg5/cc-connect/core"
)
//go:embed all:dist
var distFS embed.FS
func init() {
sub, err := fs.Sub(distFS, "dist")
if err != nil {
panic("web: embed dist: " + err.Error())
}
core.RegisterWebAssets(sub)
}