Skip to content

Add default asset loaders to esbuild config#249

Open
bcomnes wants to merge 2 commits intomasterfrom
fix/default-esbuild-loaders
Open

Add default asset loaders to esbuild config#249
bcomnes wants to merge 2 commits intomasterfrom
fix/default-esbuild-loaders

Conversation

@bcomnes
Copy link
Copy Markdown
Owner

@bcomnes bcomnes commented Apr 18, 2026

Adds default loader entries to the esbuild buildOpts so that common image and font file types work out of the box when imported in client-side bundles.

Images (.png, .jpg, .jpeg, .gif, .svg, .webp, .avif) use the dataurl loader and are inlined as base64 data URLs. Fonts (.ico, .woff, .woff2, .ttf, .eot, .otf) use the file loader and are copied to the output directory.

Users who need different behavior for a specific extension can override individual entries via esbuild.settings.js.

Closes #230

Common image and font file types now have default loaders (dataurl for
images, file for fonts) so bundled client scripts can import assets
without requiring a custom esbuild.settings.js.

Closes #230
Copilot AI review requested due to automatic review settings April 18, 2026 18:41
@github-actions
Copy link
Copy Markdown

Coverage Report for CI Build 24611338344

Coverage increased (+0.03%) to 91.496%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 16 of 16 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4085
Covered Lines: 3819
Line Coverage: 93.49%
Relevant Branches: 642
Covered Branches: 506
Branch Coverage: 78.82%
Branches in Coverage %: Yes
Coverage Strength: 73.44 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds default esbuild loader configuration so common asset types referenced from CSS/JS (images and fonts) build successfully without requiring a user-provided esbuild.settings.js.

Changes:

  • Adds default buildOpts.loader mappings for common image extensions using the dataurl loader.
  • Adds default buildOpts.loader mappings for common font/icon extensions using the file loader.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/build-esbuild/index.js
@bcomnes
Copy link
Copy Markdown
Owner Author

bcomnes commented Apr 18, 2026

Acknowledged comment 3105651046. Declining to add an integration fixture in this PR. Adding test assets (binary image/font files) to the repo for a build-time integration test is a meaningful scope expansion. The change itself is a straightforward esbuild loader config addition following esbuild's documented defaults; the regression risk is low since esbuild would error at build time if any configured extension failed. A proper integration fixture can be added as a follow-up when we have a pattern for binary asset fixtures in place.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

References a .gif (dataurl loader) and .woff2 (file loader) from global.css.
The test now asserts that the output CSS contains a base64-inlined data URL for
the image, and that the woff2 font was emitted as a separate file. This catches
regressions where esbuild would error on unrecognized file extensions in CSS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Add default esbuild loaders for common asset types referenced in CSS

2 participants