A simple cli tool to serve a folder containing a SPA application, with basic proxy capabilities.
- serve from a folder using cli args or a config file
- respond to
htmlrequests with the rootindex.html - serve from a tar archive (the
tarexecutable must be present) - serve from an url pointing to a tar archive (soon™)
- proxy some calls to other apps (à la webpack dev-server proxy, but with less features)
- use
~and environnement variables in application path
Assuming an angular v8 app called project-name, and built with ng build.
In one line:
$ spa-server -s dist/project-name
# will serve the folder dist/project-name on http://localhost:4242If you want to have proxies, customize the host or the port, you must use a config file. Given one called Spa-project-name.toml:
[server]
port = 4200
serve = "~/git/project-name/dist/project-name" # support for `~` in paths
[proxies]
"/api" = { target = "http://localhost:8080" }
# example: http://localhost:4200/api/hello will be forwarded to http://localhost:8080/api/helloJust run spa-server Spa-project-name.toml and you're ready to go!
For a complete documentation about the config file, your best bet right now is the documentation of the Config struct.
First, Rust must be installed. You can then install this binary from git:
$ cargo install --force --git https://github.com/justinrlle/spa-serverTODO
- serve from url
- other protocols
- s3 (
aws-cliorrusoto?) - ftp
- ssh?
- git?
- s3 (
- windows support for archives
- better testing for archives
- feature parity with webpack dev-server proxy
- cli option to define simple proxies (possible syntax:
spa-server --forward /api=http://localhost:8080) - figure out how to use secrets in application path
- stay with plain old environnement variables and
dotenvfile loading? - use of
secret-tool,gnome-keychain, Keychain Access on macOS?
- stay with plain old environnement variables and