Bundling angular2 application in rust app


I’m currently learning angular2 (and typescript) in order to write a web front-end for the requirements tracking tool I am developing.

What I would like to do is:

  • write the web application in angular2
  • compile the web-app into a single html/js/etc file – all contained in a single file. Angular2 is supposed to be good at this from my understanding (single page application)
  • bundle this single file into my rust-app’s binary and have a way for the rust-app to specify the url that the rust backend will be running on (maybe simply formatting a string?)
  • use a rust web-framework to simply serve this html file – there should be no dependencies on node.js or anything else
  • write the rust backend as a json-rpc server that the angular2 app will connect with.

When I was looking for examples of this, I found rustsite-example, but it requires you to have node and npm installed. I do not want to have to require my users to install those dependencies (developers will obviously have to install those dependencies).

Any help would be appreciated, even if it is someone just telling me that this is or isn’t possible.


Hi @vitiral,

a similar question was asked here:

And yes it’s possible. You can use Iron for example to serve static files. I haven’t done json-rpc yet but this should also be possible - there is even a crate for that.


Hey, thanks for the response Willi!

Do you know how to bundle a file into a static binary? Is there some kind of module that can be used for that?


You should be able to use include_str! for that.


Thanks, I’ve somehow never seen that!