Skip to content

fix(build): sync frontend assets to embed dir when frontend:dir is custom#5188

Closed
leaanthony wants to merge 1 commit into
masterfrom
fix/5034-frontend-dir-embed
Closed

fix(build): sync frontend assets to embed dir when frontend:dir is custom#5188
leaanthony wants to merge 1 commit into
masterfrom
fix/5034-frontend-dir-embed

Conversation

@leaanthony

Copy link
Copy Markdown
Member

Summary

  • When frontend:dir in wails.json is set to a non-default directory, wails build now correctly syncs the built frontend assets to the //go:embed directory
  • The go:embed directive in main.go is 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 time
  • After BuildFrontend, a new syncFrontendAssetsToEmbedDir step copies assets from <custom-frontend>/dist to frontend/dist
  • No-op when frontend:dir is the default "frontend"

Test Plan

  • v2/pkg/commands/build/sync_test.go contains 4 tests:
    • TestSyncAssetsToEmbedPathsCopiesFromCustomDir — verifies assets are copied from custom dir to embed dir
    • TestSyncFrontendAssetsNoOpForDefaultDir — verifies no copying when frontend:dir is default
    • TestSyncFrontendAssetsNoOpForNilProject — verifies nil safety
    • TestCopyDir — verifies the recursive directory copy utility

Related Issue

Fixes #5034

Notes

  • Does not modify //go:embed directives (that would require rewriting user source code)
  • For frontends outside the project directory, this fix works for relative paths. Absolute paths outside the project remain unsupported due to go:embed limitations.
  • This is a v2-only fix.

@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3838975a-0cb8-4fe7-b552-e5c92a4e3918

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/5034-frontend-dir-embed

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…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
@leaanthony leaanthony force-pushed the fix/5034-frontend-dir-embed branch from 432ce79 to deeeef1 Compare April 24, 2026 13:20
@leaanthony leaanthony modified the milestones: v2.5.0, v2.13.0 May 20, 2026
@taliesin-ai

Copy link
Copy Markdown
Collaborator

Superseded by #5251 (build now syncs frontend dist into the embed target). This was an earlier WIP for the same fix; closing as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] Fully built apps fail to run when frontend:dir is not default

2 participants