Skip to content

fix(v2): copy frontend build output to embed target when frontend:dir is custom#5178

Closed
leaanthony wants to merge 2 commits into
masterfrom
v2-bugfix/5034-frontend-dir-embed
Closed

fix(v2): copy frontend build output to embed target when frontend:dir is custom#5178
leaanthony wants to merge 2 commits into
masterfrom
v2-bugfix/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 (e.g. "jsfrontend" instead of "frontend"), the //go:embed all:frontend/dist directive in main.go still looks at frontend/dist. The built assets end up in jsfrontend/dist, so the compiled binary has no frontend assets — just the gitkeep placeholder.

This PR adds a syncFrontendToEmbedTarget() function that runs after BuildFrontend. When the frontend dir differs from the default, it copies the built dist contents to the embed target directory (determined via static analysis of //go:embed directives).

Limitations:

  • Only works when the custom frontend directory is within the project tree
  • External frontend directories (e.g. ../frontend) cannot be supported due to Go's embed path restrictions (no .. allowed)
  • Users with external frontends must still manually update their //go:embed directive to match their frontend:dir

Test case:

  1. wails init -n client
  2. Rename frontend to jsfrontend
  3. Add "frontend:dir": "./jsfrontend" to wails.json
  4. wails build → app now works correctly

Fixes #5034

… is custom

When frontend:dir in wails.json is set to a non-default directory (e.g.
"jsfrontend" instead of "frontend"), the Go embed directive
//go:embed all:frontend/dist still looks at frontend/dist, but the
built assets are in the custom directory's dist folder. This causes
the compiled binary to have no frontend assets.

After BuildFrontend completes, if the frontend dir differs from the
default "frontend", this change copies the built dist contents to the
embed target directory so the Go compiler can find them.

Only applies when the custom frontend directory is within the project
tree. External frontend directories (../foo) are not supported due to
Go embed's path restrictions.

Fixes #5034
@coderabbitai

coderabbitai Bot commented Apr 19, 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: 0deb7c72-84c9-4fee-b771-5a688633ef7c

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 v2-bugfix/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.

@leaanthony

Copy link
Copy Markdown
Member Author

Closing in favor of #5251

@leaanthony leaanthony closed this May 31, 2026
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

1 participant