Feature request: Allow custom mount point and folder name for static content
Right now static content is always read from static and mounted at the root. It would be useful to be able to decide through command line parameters:
- where the static content is read from, eg:
cargo web start --static-folder=assets
- where the static content is mounted in the server
cargo web start --static-mount=/assets
This among other things would make it easier to have files that can be read from a desktop version of an application and the wasm one while testing from the same folder using the same relative paths.
For example in the examples above one might have assets to an application stored in an assets folder. When reading them compiling an application as desktop one can read the files using File::open or any other file reading facilities as:
File::open("assets/image.png").unwrap()
And from the web as:
load_img("assets/image.png")
Where load_img is for example a function using something like: https://gist.github.com/kngwyu/a92b784195aab433143a582b248f4112 to read an image asynchronously.
This allows to have resources in any folder and to have the paths stored for example in constants or config files that are the same for both a desktop and web version of the same application.
If this is of any interest I can look into sending a PR
Definitely! Although instead of putting those on the command line they should be specified in Web.toml. (In general I'd like to never have to require the users to pass any special parameters to cargo web start for it to work properly.)