fix(build): sync frontend assets to embed dir when frontend:dir is custom#5188
fix(build): sync frontend assets to embed dir when frontend:dir is custom#5188leaanthony wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…n-default When frontend:dir is set to a directory other than the default "frontend", the built assets end up in the custom directory's dist/ folder but the go:embed directive in main.go still points to frontend/dist. This causes the built binary to have no frontend assets. After BuildFrontend completes, detect if the frontend dir differs from the embed target and copy the built assets to the embed directory so the Go compiler can find them. Fixes #5034
432ce79 to
deeeef1
Compare
|
Superseded by #5251 (build now syncs frontend dist into the embed target). This was an earlier WIP for the same fix; closing as done. |
Summary
frontend:dirinwails.jsonis set to a non-default directory,wails buildnow correctly syncs the built frontend assets to the//go:embeddirectorygo:embeddirective inmain.gois hardcoded (e.g.,//go:embed all:frontend/dist), so when the frontend is in a custom directory, the assets end up in the wrong place at compile timeBuildFrontend, a newsyncFrontendAssetsToEmbedDirstep copies assets from<custom-frontend>/disttofrontend/distfrontend:diris the default"frontend"Test Plan
v2/pkg/commands/build/sync_test.gocontains 4 tests:TestSyncAssetsToEmbedPathsCopiesFromCustomDir— verifies assets are copied from custom dir to embed dirTestSyncFrontendAssetsNoOpForDefaultDir— verifies no copying when frontend:dir is defaultTestSyncFrontendAssetsNoOpForNilProject— verifies nil safetyTestCopyDir— verifies the recursive directory copy utilityRelated Issue
Fixes #5034
Notes
//go:embeddirectives (that would require rewriting user source code)go:embedlimitations.