From b390a5f0edff9c6303bf6d0799644a07c3d54411 Mon Sep 17 00:00:00 2001 From: Jonathan Knapp Date: Mon, 23 Mar 2020 08:25:12 -0400 Subject: [PATCH] Add serve command to build and serve static files - needed an http server to serve 'wasm' extension - I typically use nginx in one-time docker container run mapped to local directory to serve files - needed to add custom nginx config to serve "application/wasm" mime type - interested in adding info to Yew docs, looked at website which I then looked at Rollup example source - they recommend using python http server - found myself on Rust WASM RFCs github page with "watch and serve" command RFC - https://github.com/rustwasm/rfcs/pull/10 --- .gitignore | 1 - bin/serve.sh | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 bin/serve.sh diff --git a/.gitignore b/.gitignore index 4e30131..e0dc1bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /target **/*.rs.bk Cargo.lock -bin/ pkg/ wasm-pack.log diff --git a/bin/serve.sh b/bin/serve.sh new file mode 100755 index 0000000..9789943 --- /dev/null +++ b/bin/serve.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +wasm-pack build --target web + +cd pkg +echo "Server started at http://localhost:8000 from $PWD" +docker run -p 8000:80 --rm -v "$HOME/.profile_sources/server/custom-types.conf":/etc/nginx/conf.d/custom-types.conf:ro -v "$PWD":/usr/share/nginx/html:ro nginx:alpine