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 "$@"
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"
// ...
}
// ...
}
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.