Settings

Theme

Show HN: Embed ViteJS-compiled assets in your Rust binary

github.com

2 points by lionside a year ago · 1 comment · 1 min read

Reader

Dear HN community --

Merry Christmas, Happy Hannukah, and all the best in the upcoming new year :)

Just wanted to share a crate I've been working on that I finally felt was ready to publish. It's primary purpose is to make it easy to integrate ViteJS with your Rust project. It tries to be a low-touch integration so you can continue using ViteJS as you normally would.

The next step for this is to show the community how you could integrate this into templating engines and web frameworks like `actix-web`/`axum`/`poem`/etc. I've previously drafted a ViteJS integration for Rust backends[1] in `create-react-app` and I hope to adapt that to use `vite-rs` soon.

[1] https://github.com/Wulf/create-rust-app/blob/main/create-rus...

lionsideOP a year ago

Oh, one more thing! I'd like to share an excerpt from the README to make sure folks considering this approach understand all the cons that I could think of:

```

As with all things in life, there are considerations to take into account before using vite-rs:

    It's one more thing to debug when things go wrong.

    It'll increase compile time. See the note on compile times for large assets.

    For those deploying to embedded devices: it'll increase your binary size.

    Shipping frontend with your backend can slow you down as you'll have to wait for your Rust backend to compile everytime you want to release a new build. Similarly, failing CI/CD pipelines pertaining to the backend will also stop your frontend frontend from deploying.

    It may be faster or cheaper to deploy your frontend on CDNs instead of serving it.
```

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection