2018-08-25 18:18:42 -04:00
|
|
|
DIR="$(dirname $0)"
|
|
|
|
WASM_DIR="$DIR/target/wasm32-unknown-unknown"
|
|
|
|
WASM_NAME="$(cat "$DIR/Cargo.toml" | grep name | sed 's/name = "//' | sed 's/"//g')"
|
2018-09-08 21:56:06 -04:00
|
|
|
APP_DIR="$DIR/dist/"
|
2018-08-25 18:18:42 -04:00
|
|
|
|
|
|
|
if [ ! -d "$APP_DIR" ]; then
|
|
|
|
mkdir "$APP_DIR"
|
|
|
|
fi
|
2018-09-08 21:56:06 -04:00
|
|
|
cp "$DIR/static/"* "$APP_DIR"
|
2018-08-25 18:18:42 -04:00
|
|
|
|
|
|
|
if [ -z "$(which cargo)" ]; then
|
|
|
|
echo 'Must install `cargo` before proceeding. Please see https://rustup.rs/ for more information.'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$(which wasm-bindgen)" ]; then
|
|
|
|
echo "Installing wasm-bindgen-cli"
|
|
|
|
cargo install wasm-bindgen-cli
|
|
|
|
fi
|
|
|
|
|
2018-09-08 22:36:48 -04:00
|
|
|
# Patch from: https://github.com/webpack/webpack/pull/7983
|
|
|
|
cp "$DIR/WasmMainTemplatePlugin.patched.js" "$DIR/node_modules/webpack/lib/wasm/WasmMainTemplatePlugin.js"
|
|
|
|
|
2018-08-25 18:18:42 -04:00
|
|
|
cargo +nightly build --target=wasm32-unknown-unknown && \
|
|
|
|
wasm-bindgen "$WASM_DIR/debug/$WASM_NAME.wasm" --out-dir "$APP_DIR" --no-typescript && \
|
2018-09-12 22:40:19 -04:00
|
|
|
# --mode=production requires https://github.com/webpack/webpack/pull/7732
|
2018-09-08 22:36:48 -04:00
|
|
|
"$DIR/node_modules/webpack-cli/bin/cli.js" --mode=production "$APP_DIR/app_loader.js" -o "$APP_DIR/bundle.js"
|