Azure / Azure/static-web-apps

Set the destination directory

Open
#1,052 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Hey there,

I was working with Adrian on support request 2301110040009179 to try and understand if there was a straight forward way to deploy our static web app to a subdirectory. (Not sure if y'all have access to that same tracking system, but just in case I included that Support Request ID.)

Basically all we would like to do, in a simple and straight forward configuration setting, is to be able to set the destination directory. For example; ourdomain.com/our-static-web-app

I wanted to put in a feature request to be able to do so without having to conjure up a workaround, which we have. I'll explain.

We have a domain, teachforamerica.org, and we have a website, or let's say, index.html at the root of that domain already. We plan on deploying several static web applications in several paths, each on their own static web app resource so we can maintain those separately and route to them via CDN. For example; /eligibility, or /apply, etc.

What we have done is:
1. set the workflow file `output_location` to /dist
2. set our vite build `outDir` to dist/eligibility
3. at the end of our build, or `closeBundle` vite hook, we copy the index.html from the /dist/eligibility directory to the /dist directory (so we pass checks for the index.html at the root)
4. in the staticwebapp.config.json we set `routes` to redirect to /eligibility/ if the root index.html is visited.
```
"routes": [
{
"route": "/index.html",
"redirect": "/eligibility/"
}
]
```

What would be great is if we didn't have to do this and we were able to simply set the destination directory and have the service check the set destination directory for the index.html vs as the root.

It looks as though others have been needing the same capability. (https://github.com/Azure/static-web-apps/issues/351, and https://github.com/Azure/static-web-apps/issues/671) Could this be in store for the future?

Thank you so much for y'all's time!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.