Skip to content

fix: netlify.toml + optimize token images WebP (-99% tamaño) - #4

Merged
jacxas merged 3 commits into
masterfrom
fix/netlify-config-and-optimize-images
Jul 8, 2026
Merged

fix: netlify.toml + optimize token images WebP (-99% tamaño)#4
jacxas merged 3 commits into
masterfrom
fix/netlify-config-and-optimize-images

Conversation

@jacxas

@jacxas jacxas commented Jul 8, 2026

Copy link
Copy Markdown
Owner

¿Qué arregla este PR?

1. netlify.toml — Fix checks rojos en PRs

Los 3 checks de Netlify fallaban en cada PR porque Netlify no sabía cómo buildear el proyecto Vite/React. Este archivo lo arregla:

  • base = "frontend" → apunta al directorio correcto
  • command = "npm install && npm run build" → build de Vite
  • publish = "dist" → carpeta de salida
  • [[redirects]] /* → /index.html → SPA routing (React Router)
  • ✅ Cache headers para imágenes y assets estáticos (max-age=31536000)
  • NODE_VERSION = "20" → misma versión que Vercel

2. Imágenes de tokens optimizadas: .jpg.webp

Las 10 imágenes originales pesaban 21.8 MB en total. Ahora pesan 156 KB (-99%):

Token Antes Después Reducción
AGOV 1,980 KB 14 KB -99%
AUTI 2,571 KB 18 KB -99%
APAY 1,883 KB 11 KB -99%
ARES 1,506 KB 16 KB -99%
A1GOV 2,204 KB 16 KB -99%
A1UTI 2,261 KB 15 KB -99%
A1PAY 2,484 KB 17 KB -99%
AXGOV 2,466 KB 15 KB -99%
AXPAY 2,635 KB 17 KB -99%
AXRES 1,834 KB 17 KB -99%
Total 21,824 KB 156 KB -99%

Formato WebP 256×256px (más que suficiente para el UI, que los muestra a 56px / w-14 h-14).

tokens.js actualizado para referenciar /tokens/*.webp en lugar de /tokens/*.jpg.

Resultado esperado

  • ✅ Checks de Netlify pasan en verde en el próximo PR
  • ✅ Exchange carga instantáneo (sin descargar 21 MB de imágenes)
  • ✅ Vercel preview deploy sigue funcionando igual

Summary by Sourcery

Configure Netlify to correctly build and serve the frontend and switch token images to optimized WebP assets to improve performance.

New Features:

  • Add Netlify configuration to build the Vite/React frontend and serve it as a SPA with appropriate redirects and cache headers.

Enhancements:

  • Replace token JPG images with lightweight WebP versions and update token metadata to reference the new assets, significantly reducing image payload size.

@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for cryptoysuite failed.

Name Link
🔨 Latest commit 184295b
🔍 Latest deploy log https://app.netlify.com/projects/cryptoysuite/deploys/6a4ee06cf6e70e0008ae2cc0

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crypto-suite Error Error Jul 8, 2026 11:43pm
crypto-suite-w9qw Building Building Preview, Comment Jul 8, 2026 11:43pm

@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Configures Netlify to build and serve the Vite/React frontend correctly and switches token images to optimized WebP assets with long-lived cache headers.

Sequence diagram for SPA routing and cached token images via Netlify

sequenceDiagram
  actor User
  participant Browser
  participant Netlify
  participant ReactApp

  User->>Browser: Navigate to /exchange
  Browser->>Netlify: GET /exchange
  Netlify-->>Browser: 200 index.html (rewrite /* to /index.html)
  Browser->>Netlify: GET /assets/app.js
  Netlify-->>Browser: 200 app.js (Cache-Control max-age=31536000)
  Browser->>ReactApp: Execute app.js
  ReactApp->>Netlify: GET /tokens/agov.webp
  Netlify-->>ReactApp: 200 agov.webp (Cache-Control max-age=31536000, immutable)
Loading

File-Level Changes

Change Details Files
Configure Netlify build, SPA routing, environment, and asset caching for the Vite/React frontend.
  • Sets Netlify build base to the frontend directory, uses the Vite build command, and publishes the dist output folder.
  • Aligns Netlify Node runtime to version 20 via build.environment.
  • Adds SPA-compatible redirect from all routes to index.html for React Router.
  • Configures long-term cache headers for token images, JS, and CSS assets.
netlify.toml
Switch token image assets from heavy JPEGs to lightweight WebP files and update references.
  • Replaces token image paths in token metadata to point to .webp files instead of .jpg.
  • Adds new 256x256 WebP token images for all token variants under the public tokens directory.
  • Keeps token metadata structure unchanged aside from image paths to avoid behavioral changes.
frontend/src/data/tokens.js
frontend/public/tokens/a1gov.webp
frontend/public/tokens/a1pay.webp
frontend/public/tokens/a1uti.webp
frontend/public/tokens/agov.webp
frontend/public/tokens/apay.webp
frontend/public/tokens/ares.webp
frontend/public/tokens/auti.webp
frontend/public/tokens/axgov.webp
frontend/public/tokens/axpay.webp
frontend/public/tokens/axres.webp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jacxas
jacxas merged commit 3f023d9 into master Jul 8, 2026
2 of 10 checks passed
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix Netlify build config and switch token images to WebP

🐞 Bug fix ✨ Enhancement ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Add Netlify build config for Vite/React to stop failing deploy checks on PRs.
• Switch token image references from JPG to WebP to cut frontend transfer size.
• Add SPA redirect + long-lived cache headers for static assets on Netlify.
Diagram

graph TD
  N["Netlify"] --> C["netlify.toml"] --> B["Vite build"] --> D["dist React app"] --> J["tokens.js"] --> I["Token images (.webp)"]
  U["Browser"] --> D
  C --> R["SPA redirect"]
  C --> H["Cache headers"] --> I
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use `npm ci` instead of `npm install` on Netlify
  • ➕ Deterministic installs using the lockfile (more reproducible builds).
  • ➕ Typically faster and less error-prone in CI.
  • ➖ Requires ensuring a compatible lockfile is committed and kept up-to-date.
2. Align cache header patterns with Vite output paths
  • ➕ Ensures caching applies to hashed bundles under typical /assets/* output.
  • ➕ Avoids a false sense of caching if patterns like /*.js don’t match built files.
  • ➖ Needs confirming actual output structure in dist/ (may vary if config changes).
3. Remove legacy `.jpg` assets or add explicit fallback
  • ➕ Removing JPGs reduces repo/deploy artifact size further.
  • ➕ Fallback via `` can improve compatibility if any client can’t render WebP.
  • ➖ Removing JPGs can break any external references/bookmarks to old file names.
  • ➖ Fallback adds a small amount of UI complexity.

Recommendation: Keep the netlify.toml-based approach (it’s the right place for portable Netlify config), but consider switching to npm ci for reproducibility. Also verify cache header globs match the actual Vite build output (often /assets/*), and decide whether to delete leftover JPGs (smaller deploy) or keep them intentionally for backward compatibility.

Files changed (2) +37 / -10

Enhancement (1) +10 / -10
tokens.jsSwitch token image URLs from .jpg to .webp +10/-10

Switch token image URLs from .jpg to .webp

• Updates the 'img' field for all token entries to reference '/tokens/*.webp' instead of '/tokens/*.jpg'. This matches the optimized asset format and reduces image transfer size for the UI.

frontend/src/data/tokens.js

Other (1) +27 / -0
netlify.tomlAdd Netlify build/publish config, SPA redirects, and cache headers +27/-0

Add Netlify build/publish config, SPA redirects, and cache headers

• Introduces Netlify configuration pointing builds at the 'frontend' base, running the Vite build, and publishing 'dist'. Adds a catch-all redirect to '/index.html' for SPA routing and long-lived cache headers for tokens and static JS/CSS assets, plus NODE_VERSION=20.

netlify.toml

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The Netlify headers for JS and CSS use patterns like /*.js and /*.css, which only match files in the root; consider switching to something like /assets/*.js and /assets/*.css (or /*) so the built Vite bundles under /assets/ also get the long-term cache headers.
  • Now that all token images live under /tokens/*.webp, you might want to centralize the base path and extension in a small helper or constant (e.g. getTokenImg(ticker)), so future format or path changes don't require touching every token entry.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Netlify headers for JS and CSS use patterns like `/*.js` and `/*.css`, which only match files in the root; consider switching to something like `/assets/*.js` and `/assets/*.css` (or `/*`) so the built Vite bundles under `/assets/` also get the long-term cache headers.
- Now that all token images live under `/tokens/*.webp`, you might want to centralize the base path and extension in a small helper or constant (e.g. `getTokenImg(ticker)`), so future format or path changes don't require touching every token entry.

## Individual Comments

### Comment 1
<location path="netlify.toml" line_range="1-4" />
<code_context>
+[build]
+  base    = "frontend"
+  command = "npm install && npm run build"
+  publish = "dist"
+
</code_context>
<issue_to_address>
**suggestion (performance):** Consider using `npm ci` instead of `npm install` in the Netlify build for reproducibility and speed.

In CI/CD pipelines, `npm ci` is the recommended choice as it installs strictly from `package-lock.json`. Only keep `npm install` if you explicitly need to modify or regenerate the lockfile during the build.

```suggestion
[build]
  base    = "frontend"
  command = "npm ci && npm run build"
  publish = "dist"
```
</issue_to_address>

### Comment 2
<location path="netlify.toml" line_range="19-22" />
<code_context>
+  to     = "/index.html"
+  status = 200
+
+[[headers]]
+  for = "/tokens/*"
+  [headers.values]
+    Cache-Control = "public, max-age=31536000, immutable"
+
+[[headers]]
+  for = "/*.js"
+  [headers.values]
+    Cache-Control = "public, max-age=31536000, immutable"
</code_context>
<issue_to_address>
**suggestion:** Header pattern for JS files may only match root-level files, missing nested asset paths.

The pattern `"/*.js"` only targets files directly under `/`. Any JS emitted in nested directories (e.g., `/assets/index-XXXXX.js` or `/static/js/app.js`) would miss these cache headers. Consider using a recursive pattern like `"/**/*.js"` or a path that matches your actual build output.

```suggestion
[[headers]]
  for = "/**/*.js"
  [headers.values]
    Cache-Control = "public, max-age=31536000, immutable"
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread netlify.toml
Comment thread netlify.toml
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