jaspr icon indicating copy to clipboard operation
jaspr copied to clipboard

Provide a way to override the base href in `jaspr build`

Open juancastillo0 opened this issue 3 years ago • 0 comments

Hi,

I wonder whether it would be a good idea to implement something within the framework to specify the base href for the generated html. Specially for the build command. This would allow for the developer to not worry about changing the html file between development and production, similar to Flutter's flutter build --web --base-href "/example/". Not sure how that part is implemented, but maybe it could also be used for the package:shelf handler example when one uses a different route. I know it is not that hard to just change the value in CI, however I though I would make an issue to discuss it and know what you think.

Following Flutter, maybe something like this could be inserted in the project generated by jaspr create:

<base href="$JASPR_BASE_HREF"></base>

Or maybe override it if any base tag is found and a --base-href is passed as argument to jaspr build or perhaps a PUBLIC_URL env variable like in react or the base config in vite and next (I have not used it, but the docs say it serves that purpose).

In a new Flutter project the following is generated within the web/index.html:

If you are serving your web app in a path other than the root, change the href value below to reflect the base path you are serving from.

The path provided below has to start and end with a slash "/" in order for it to work correctly.

For more details:

  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

This is a placeholder for base href that will be replaced by the value of the --base-href argument provided to flutter build.

<base href="$FLUTTER_BASE_HREF">

Thanks!

juancastillo0 avatar Aug 04 '22 02:08 juancastillo0