diff --git a/core/scripts/vercel-build.sh b/core/scripts/vercel-build.sh index daf44142dce..6402e3bd247 100755 --- a/core/scripts/vercel-build.sh +++ b/core/scripts/vercel-build.sh @@ -3,12 +3,14 @@ # Vercel preview build script # # Builds core component tests (same as before) plus framework test apps -# (Angular, React, Vue) so they're all accessible from a single preview URL. +# (Angular, React, React Router, Vue) so they're all accessible from a single +# preview URL. # -# Core tests: /src/components/{name}/test/{scenario} -# Angular test app: /angular/ -# React test app: /react/ -# Vue test app: /vue/ +# Core tests: /src/components/{name}/test/{scenario} +# Angular test app: /angular/ +# React test app: /react/ +# React Router test app: /react-router/ +# Vue test app: /vue/ # set -e @@ -62,6 +64,12 @@ generate_dir_index() { # Skip if an index.html already exists (it's an actual test page) [ -f "${dir}/index.html" ] && return + # Absolute hrefs based on url_path. Vercel does not redirect to add trailing + # slashes, so a relative href like "basic/" from a URL without a trailing + # slash resolves against the parent directory and breaks navigation. + local parent_path="${url_path%/}" + parent_path="${parent_path%/*}/" + local entries="" for child in "${dir}"/*/; do [ -d "${child}" ] || continue @@ -70,7 +78,7 @@ generate_dir_index() { case "${name}" in *-snapshots|.*) continue ;; esac # Only include if there's at least one index.html somewhere underneath find "${child}" -name "index.html" -print -quit | grep -q . || continue - entries="${entries}${name}/\n" + entries="${entries}${name}/\n" done [ -z "${entries}" ] && return @@ -92,7 +100,7 @@ generate_dir_index() {