Skip to content

Conversation

@Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Feb 5, 2026

This saves about 75mb of image size

Summary by Sourcery

Enable pre-compressed gzip asset delivery in the frontend build and nginx configuration.

New Features:

  • Add Vite compression plugin to generate gzip-compressed frontend assets during build.

Enhancements:

  • Configure nginx to always serve pre-compressed .gz files via gzip_static and simplify asset location handling.

Build:

  • Add vite-plugin-compression dependency and integrate it into the Vite config to gzip selected asset types.

Deployment:

  • Update nginx configuration to serve pre-compressed static assets from the frontend build output.

@Williangalvani Williangalvani marked this pull request as draft February 5, 2026 18:16
@sourcery-ai
Copy link

sourcery-ai bot commented Feb 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds gzip pre-compression of selected frontend build assets via Vite and configures nginx to always serve these .gz files from /assets, removing the need for try_files and the original uncompressed assets.

Sequence diagram for serving pre-compressed frontend assets

sequenceDiagram
    participant Browser
    participant Nginx
    participant FrontendAssets as Frontend_assets_directory

    Browser->>Nginx: GET /assets/app.js
    Nginx->>FrontendAssets: Lookup app.js.gz (gzip_static always)
    alt app.js.gz exists
        Nginx-->>Browser: 200 app.js.gz
        Browser->>Browser: Decompress gzip and execute JS
    else app.js.gz missing or client no gzip
        Nginx-->>Browser: 404 or fallback response
    end
Loading

File-Level Changes

Change Details Files
Enable gzip pre-compression of frontend build assets during Vite build.
  • Import vite-plugin-compression into the Vite config.
  • Register viteCompression in the plugins array with gzip algorithm, .gz extension, 1KB threshold, and deletion of original files.
  • Restrict compression to specific asset types including JS, CSS, JSON, SVG, text, XML, WASM, and GLB files.
core/frontend/vite.config.js
Configure nginx to serve pre-compressed .gz assets and simplify /assets/ location handling.
  • Enable gzip_static always at the http level so nginx serves .gz files even if originals are missing, when the client supports gzip.
  • Simplify the /assets/ location by removing try_files, relying on nginx static file resolution under the configured root.
  • Keep caching headers for /assets/ unchanged while serving pre-compressed content.
core/tools/nginx/nginx.conf
Declare vite-plugin-compression as a frontend dependency.
  • Add vite-plugin-compression to devDependencies in the frontend package.json with version ^0.5.1.
core/frontend/package.json

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Using deleteOriginFile: true means only .gz assets will be deployed; consider whether any non-gzip-capable clients, tooling, or direct file access (e.g. via S3/bucket browsing or other servers) rely on the original files and whether it’s safer to keep them.
  • Removing try_files $uri $uri/; from the /assets/ location changes how missing or directory requests are handled; confirm that you don’t rely on any fallback behavior there (e.g. serving a default file or index) and that 404 handling remains as intended.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `deleteOriginFile: true` means only `.gz` assets will be deployed; consider whether any non-gzip-capable clients, tooling, or direct file access (e.g. via S3/bucket browsing or other servers) rely on the original files and whether it’s safer to keep them.
- Removing `try_files $uri $uri/;` from the `/assets/` location changes how missing or directory requests are handled; confirm that you don’t rely on any fallback behavior there (e.g. serving a default file or index) and that 404 handling remains as intended.

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.

This saves about 75mb of image size
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Using viteCompression with deleteOriginFile: true means the build output only contains .gz versions of the filtered assets; consider keeping originals (or limiting this to assets you know are only fetched via nginx with Accept-Encoding: gzip) to avoid breaking any non-gzip consumers or tooling that expects raw files.
  • Enabling gzip_static always; in nginx will serve .gz files even when the client does not send Accept-Encoding: gzip; consider using gzip_static on; instead (or a more targeted location block) to avoid corrupt responses for clients or intermediaries that cannot handle gzip-encoded content.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `viteCompression` with `deleteOriginFile: true` means the build output only contains `.gz` versions of the filtered assets; consider keeping originals (or limiting this to assets you know are only fetched via nginx with `Accept-Encoding: gzip`) to avoid breaking any non-gzip consumers or tooling that expects raw files.
- Enabling `gzip_static always;` in nginx will serve `.gz` files even when the client does not send `Accept-Encoding: gzip`; consider using `gzip_static on;` instead (or a more targeted location block) to avoid corrupt responses for clients or intermediaries that cannot handle gzip-encoded content.

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.

@patrickelectric patrickelectric merged commit b64f29f into bluerobotics:master Feb 9, 2026
7 checks passed
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.

2 participants