Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds some environment variables to allow cloud IDE to configure the Vite plugin so that things just work out of the box.
There are some current limitations that cloud IDE environments may hit.
The first is that Vite will likely need to run listening on all interfaces. Although this can be manually achieved via
npm run dev -- --host
, I have added an environment value that allows this to be the default behaviour.With the value in the environment, Vite will automatically listen on all interfaces.
The next hurdle that cloud IDEs may need to customise the format of the public facing dev server URL. This is the URL that is written to the hot file, rendered in Laravel templates, and also transformed in the JavaScript and CSS files when pointing to other resources.
The default format of this URL is
{scheme}://{host}:{port}
. This results in the standard Vite URL we see locally:http://[::]:5173
.Cloud IDEs may need to have the Vite dev server listening on HTTP while the publicaly rendered URL needs to be HTTPS. Additionally, to format of the publicaly exposed URL may need to be different. For example, one cloud IDE has the format
https://{port}-{host}
.This PR introduces a new environment variable to control the publicly exposed dev server URL. The environment variable may contain hard coded information...
However, as some of these values are dynamic, e.g., the port, or configurable, e.g., the host, the environment variable may also contain placeholders that will be replaced with the actual values.
{scheme}
,{host}
, and{port}
are the supported placeholders, e.g.,You can mix and match these as needed, for example, if you only needed to retrieve the port from Vite: