Skip to content

build: emit font assets without a parent-traversal assetNames - #16

Merged
dabeecao merged 1 commit into
mainfrom
fix/esbuild-font-assets
Nov 22, 2026
Merged

dabeecao merged 1 commit into
mainfrom
fix/esbuild-font-assets

Conversation

@dabeecao

Copy link
Copy Markdown
Owner

Fixes the last thing keeping the backend's Windows CI red, and it is a real cross-platform build bug rather than a CI quirk.

Problem

The bundled CSS step used outfile plus a parent-traversal asset name:

outfile: 'static/css/style.min.css',
assetNames: '../webfonts/[name]',

That emits Font Awesome's fonts to static/webfonts/ on macOS and Linux, but nothing at all on the Windows runner. static/webfonts/ was therefore never created, and the backend failed with:

main.go:53:29: pattern web/static/webfonts: no matching files found

The error points at Go and at a go:embed directive, which is why it was worth chasing to the actual cause: the frontend build silently produced no font files on one platform.

Worth noting what was ruled out first:

  • Not a dependency version problem. That was a genuine separate bug (bun.lock was gitignored, so CI pulled Font Awesome 7.3.1 instead of 7.2.0; 7.3.1 dropped webfonts/). Fixed by committing the lockfile. After that fix the Windows log confirmed @fortawesome/fontawesome-free@7.2.0 installed correctly — and webfonts/ was still missing, which is what pointed here.
  • Not a missing file in node_modules. The fonts are present after install on every platform.
  • Not path resolution. path.win32.resolve computes the right target.

Fix

Resolve asset paths relative to an outdir instead of traversing out of an outfile — the documented approach, with no parent traversal:

entryPoints: { 'css/style.min': 'static/css/style.css' },
outdir:      'static',
assetNames:  'webfonts/[name]',

Non-CSS builds keep the simple outfile form.

Output is unchanged

  • fonts → static/webfonts/ (all four woff2 files)
  • CSS → static/css/style.min.css
  • generated url() values are ../webfonts/..., exactly as before, which the browser resolves to /static/webfonts/

Verified on macOS: clean build emits all four fonts, style.min.css is structurally identical, and the backend then passes go vet ./... and go build.

Honest limitation

I cannot exercise the Windows path locally. This change removes the construct that failed there (parent traversal in assetNames), and the output shape is the documented one, but CI on the backend Windows job is the real test. If it still fails, the next step is to check whether the asset is emitted under a differently-cased or differently-separated path on that runner rather than to guess again.

Merge note

This is a prerequisite for telecloud-go#52 (backend CI), which bumps the web/ submodule. Merge order: this PR → then the backend PR picks up a pointer containing both the lockfile and this fix.

The bundled CSS step used outfile plus assetNames: '../webfonts/[name]' to
place Font Awesome fonts in static/webfonts/. That works on macOS and Linux
but emitted nothing on the Windows CI runner, so static/webfonts/ was never
created and the backend's go:embed directive failed:

    main.go:53:29: pattern web/static/webfonts: no matching files found

Resolve asset paths relative to an outdir instead, which is the documented
way and does not depend on parent traversal:

    entryPoints: { 'css/style.min': 'static/css/style.css' }
    outdir:      'static'
    assetNames:  'webfonts/[name]'

Output is identical: fonts land in static/webfonts/, CSS in
static/css/style.min.css, and the generated url() values are
'../webfonts/...' as before, which the browser resolves to
/static/webfonts/. Non-CSS builds keep the outfile form.

Verified on macOS: all four woff2 files are emitted to static/webfonts/,
style.min.css is byte-comparable in structure to the previous output, and
the backend then passes go vet and go build. The Windows path cannot be
exercised locally, so CI is the real test.
@dabeecao
dabeecao merged commit 02b1954 into main Nov 22, 2026
6 checks passed
@dabeecao
dabeecao deleted the fix/esbuild-font-assets branch November 22, 2026 14:38
dabeecao added a commit that referenced this pull request Nov 22, 2026
* Revert "build: emit font assets without a parent-traversal assetNames (#16)"

This reverts commit 02b1954.

* Revert "ci: add test, build and locale-parity checks (#15)"

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant