With the latest launch of Bun and its newfound assist for Vite, coupled with Ruby on Rails 7.1 incorporating native assist for Bun, builders can now improve their net growth workflow considerably. Right here is the easy technique of enabling Bun for Vite Ruby, in the end 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.
Here is an instance:
{
"all": {
"viteBinPath": "bin/shims/vite"
// ...
}
// ...
}
By setting the viteBinPath
to your shim bin, you are instructing Vite Ruby to leverage Bun throughout the construct course of.
The Outcomes: A Quicker Workflow
The impression of this integration is tangible. Migrating to Bun has slashed asset processing time by 1-2 minutes, from putting in dependencies to compiling property. This optimization is especially essential for groups training Steady Supply, the place faster builds can considerably enhance general productiveness.
Paul Eager is an Open Supply Contributor and a Chief Expertise Officer at Showcase and JetThoughts. Observe him on LinkedIn or GitHub.
Should you loved this story, we suggest studying our latest tech stories and trending tech stories.