#!/usr/bin/env bash # Copies flutter.js.map next to build/web/flutter_bootstrap.js so Firefox/ # Chrome DevTools stop 404ing on "flutter.js.map" after `flutter build web`. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" OUT_DIR="${1:-$ROOT/build/web}" if [ ! -d "$OUT_DIR" ]; then echo "copy_flutter_js_source_map: output dir not found: $OUT_DIR" >&2 exit 1 fi if ! command -v flutter >/dev/null 2>&1; then echo "copy_flutter_js_source_map: flutter not on PATH" >&2 exit 1 fi FLUTTER_BIN="$(command -v flutter)" SDK_ROOT="$(cd "$(dirname "$FLUTTER_BIN")/.." && pwd)" MAP_SRC="$SDK_ROOT/bin/cache/flutter_web_sdk/flutter_js/flutter.js.map" MAP_DST="$OUT_DIR/flutter.js.map" if [ ! -f "$MAP_SRC" ]; then echo "copy_flutter_js_source_map: source map missing at $MAP_SRC" >&2 exit 1 fi cp "$MAP_SRC" "$MAP_DST" echo "copy_flutter_js_source_map: installed $MAP_DST"