[0.4] Change default SSR build directory #70
Merged
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.
This PR changes the default SSR build output directory from
storage/ssr
tobootstrap/ssr
.As pointed out in laravel/docs#8024, Envoyer symlinks the
storage
directory to preserve it between deploys. This means that anything placed in thestorage
directory on build won't be available after deploying.Background
Prior to Vite, a common location was
public/js/ssr.js
, however, Vite outputs everything to a single "build" directory (public/build
in Laravel), sopublic/js
, etc. are no longer used. We can't share the same directory for the SSR and non-SSR builds as Vite wipes the directory on build.When considering a new directory, we decided against the
public
directory because the SSR server is not downloaded by clients, and it's potentially a security issue making it public.The storage directory was originally chosen because this is a common place for Laravel to write application files. The mistake was that this directory is typically only written to at run time, rather than at build time.
With
storage
andpublic
out, we're not left with many options. Theresources
directory doesn't feel right because this typically contains source files, not compiled assets. Thebootstrap
directory seems like a good fit, as this is where Laravel already places files on build (caches, etc). We could also go with a new root-level directory, but I thinkbootstrap
makes a lot of sense.Note this is a breaking change!
Existing users relying on the default location will need to update their serve command to use the new location, otherwise it will either fail and fall back to non-SSR, or, they will run the SSR server from a prior build.
I have also PR'd Jetstream and Breeze as they both add a
.gitignore
entry for the SSR directory.