Skip to content

Commit 1f4d426

Browse files
committed
Drop ssr.tsx and pass entrypoint to vite
1 parent dfe5a44 commit 1f4d426

8 files changed

Lines changed: 21 additions & 33 deletions

File tree

app/frontend/entrypoints/inertia.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ void createInertiaApp({
4343
})
4444

4545
// This will set light / dark mode on load...
46-
initializeTheme()
46+
if (typeof localStorage !== "undefined") {
47+
initializeTheme()
48+
}

app/frontend/routes/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.2 routes of ReactStarterKit::Application.
2+
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.3 routes of ReactStarterKit::Application.
33
* @version 743c630cafd479b5d9ad42a7803e8be1fdeb9448419ce21d215b267e2b0ae749
44
* @see https://github.com/railsware/js-routes
55
*/

app/frontend/routes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.2 routes of ReactStarterKit::Application.
2+
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.3 routes of ReactStarterKit::Application.
33
* @version 743c630cafd479b5d9ad42a7803e8be1fdeb9448419ce21d215b267e2b0ae749
44
* @see https://github.com/railsware/js-routes
55
*/

app/frontend/ssr/ssr.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

config/vite.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"all": {
33
"sourceCodeDir": "app/frontend",
4+
"ssrEntrypoint": "~/entrypoints/inertia.tsx",
45
"watchAdditionalPaths": []
56
},
67
"development": {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@headlessui/react": "^2.2.0",
2222
"@inertiajs/react": "^3.0",
23-
"@inertiajs/vite": "^3.0",
23+
"@inertiajs/vite": "^3.0.0",
2424
"@radix-ui/react-avatar": "^1.1.10",
2525
"@radix-ui/react-checkbox": "^1.3.3",
2626
"@radix-ui/react-collapsible": "^1.1.12",
@@ -56,6 +56,7 @@
5656
"lint": "eslint '*.{js,mjs,cjs,ts}' app/frontend --report-unused-disable-directives --max-warnings 0",
5757
"lint:fix": "npm run lint -- --fix",
5858
"format": "prettier --check 'app/frontend' '*.{js,mjs,cjs,ts}'",
59-
"format:fix": "npm run format -- --write"
59+
"format:fix": "npm run format -- --write",
60+
"build": "vite build && vite build --ssr"
6061
}
6162
}

vite.config.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import react from "@vitejs/plugin-react"
44
import { defineConfig } from "vite"
55
import RubyPlugin from "vite-plugin-ruby"
66

7-
export default defineConfig({
8-
ssr: {
9-
// prebuilds ssr.js so we can drop node_modules from the resulting container
10-
noExternal: true,
11-
},
7+
export default defineConfig(({ command }) => ({
8+
ssr:
9+
command === "build"
10+
? { noExternal: true } // prebuild ssr.js so we can drop node_modules from the container
11+
: undefined,
1212
plugins: [
1313
react({
1414
babel: {
@@ -17,6 +17,10 @@ export default defineConfig({
1717
}),
1818
tailwindcss(),
1919
RubyPlugin(),
20-
inertia(),
20+
inertia({
21+
ssr: {
22+
entry: "./entrypoints/inertia.tsx",
23+
},
24+
}),
2125
],
22-
})
26+
}))

0 commit comments

Comments
 (0)