Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.4] Change default SSR build directory #70

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

jessarcher
Copy link
Member

@jessarcher jessarcher commented Jul 7, 2022

This PR changes the default SSR build output directory from storage/ssr to bootstrap/ssr.

As pointed out in laravel/docs#8024, Envoyer symlinks the storage directory to preserve it between deploys. This means that anything placed in the storage 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), so public/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 and public out, we're not left with many options. The resources directory doesn't feel right because this typically contains source files, not compiled assets. The bootstrap 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 think bootstrap 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.

@jessarcher jessarcher marked this pull request as ready for review July 11, 2022 00:15
@taylorotwell taylorotwell merged commit 85c6932 into main Jul 11, 2022
@taylorotwell taylorotwell deleted the move-default-ssr-location branch July 11, 2022 11:47
@taylorotwell
Copy link
Member

@jessarcher do we need to update the docs anywhere?

@jessarcher
Copy link
Member Author

@taylorotwell Yep, there's a PR at laravel/docs#8030

timacdonald pushed a commit that referenced this pull request Jul 14, 2022
* Move default SSR build directory

* Remove unnecessary npm script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants