Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?

Integrating Bun with Vite Ruby for Lightning-Fast Frontend Builds

With the current launch of Bun and its newfound help for Vite, coupled with Ruby on Rails 7.1 incorporating native help for Bun, builders can now improve their internet growth workflow considerably. Right here is the easy strategy of enabling Bun for Vite Ruby, finally streamlining your front-end builds.



Getting Began: Making a Shim Bin

To kick issues off, it’s good to create a shim bin. Navigate to the bin/shims listing and add a file named vite with the next content material:

#!/usr/bin/env bash

set -eo pipefail

bunx vite "$@"
Enter fullscreen mode

Exit fullscreen mode



Configuring Vite Ruby to Use the Shim Bin

Subsequent up, replace your Vite Ruby configuration file (config/vite.json). Specify the trail to the newly created shim bin utilizing the viteBinPath attribute.

This is an instance:

{
  "all": {
    "viteBinPath": "bin/shims/vite"
    // ...
  }
  // ...
}
Enter fullscreen mode

Exit fullscreen mode

By setting the viteBinPath to your shim bin, you are instructing Vite Ruby to leverage Bun through the construct course of.



The Outcomes: A Sooner Workflow

The affect of this integration is tangible. Migrating to Bun has slashed asset processing time by 1-2 minutes, from putting in dependencies to compiling belongings. This optimization is especially essential for groups practising Steady Supply, the place faster builds can considerably increase total productiveness.


Paul Eager is an Open Supply Contributor and a Chief Know-how Officer at Showcase and JetThoughts. Comply with him on LinkedIn or GitHub.

Should you loved this story, we advocate studying our latest tech stories and trending tech stories.

Add a Comment

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?