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

Add inertia:start-ssr and inertia:stop-ssr artisan commands #483

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

reinink
Copy link
Member

@reinink reinink commented Jan 12, 2023

This PR adds two new Inertia artisan commands for starting and stopping the Inertia SSR server:

# start the SSR server
php artisan inertia:start-ssr

# stop the SSR server
php artisan inertia:stop-ssr

The goal here is to simplify the SSR setup, removing the need to add these commands to your package.json scripts.

  "scripts": {
    "dev": "vite",
    "build": "vite build && vite build --ssr",
-   "ssr:serve": "node bootstrap/ssr/ssr.mjs",
-   "ssr:shutdown": "[ $(curl -s 'http://localhost:13714/shutdown'; echo $?) -eq 52 ]"
  },

This update includes a new inertia.ssr.bundle config option. This is the path to your local Inertia SSR bundle. By default it's set to base_path('bootstrap/ssr/ssr.mjs'), which is where the Laravel Vite plugin puts it, but you can change it to another location if needed. For example, if you're using webpack it might be located at public_path('js/ssr.js').

As part of this update I also changed the inertia.ssr.url config value to not require the /render endpoint as part of the URL, as I'm now using this URL for both rendering and shutting down. I've made this change in a backwards compatible way — meaning if your config still includes /render in the URL, we automatically strip it out.

@reinink reinink merged commit 3ef71ed into master Jan 12, 2023
@reinink reinink deleted the ssr-commands branch January 12, 2023 03:39
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.

1 participant