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

Cloud RunでのSSRに移行する #13

Open
wants to merge 8 commits into
base: functions-lock
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!.env
/functions
/scripts
2 changes: 2 additions & 0 deletions app/layouts/_components/AccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export const AccountMenu = () => {
component={Link}
to={{ pathname: 'sign-in', search: `?redirect=${currentPath}` }}
replace
prefetch='viewport'
/>
<NavLink
label='サインアップ'
component={Link}
to={{ pathname: 'sign-up', search: `?redirect=${currentPath}` }}
replace
prefetch='viewport'
/>
</>
)}
Expand Down
7 changes: 6 additions & 1 deletion app/layouts/_components/AdminNavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Link } from '@remix-run/react';
export const AdminNavMenu = () => {
return (
<Box aria-label='ナビゲーションメニュー'>
<NavLink label='書籍管理' component={Link} to='/admin/books' />
<NavLink
label='書籍管理'
component={Link}
to='/admin/books'
prefetch='viewport'
/>
</Box>
);
};
7 changes: 6 additions & 1 deletion app/layouts/_components/NavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Link } from '@remix-run/react';
export const NavMenu = () => {
return (
<Box aria-label='ナビゲーションメニュー'>
<NavLink label='書籍' component={Link} to='/books' />
<NavLink
label='書籍'
component={Link}
to='/books'
prefetch='viewport'
/>
</Box>
);
};
13 changes: 10 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '@mantine/core/styles.css';
import '@mantine/notifications/styles.css';
import '@mantine/dropzone/styles.css';
import './tailwind.css';
import { Center, Title } from '@mantine/core';
import { Center, LoadingOverlay, Title } from '@mantine/core';
import {
json,
isRouteErrorResponse,
Expand All @@ -13,6 +13,7 @@ import {
ScrollRestoration,
useRouteError,
useLoaderData,
useNavigation,
} from '@remix-run/react';
import { LoadingScreen } from '~/components/screens/LoadingScreen';
import { initializeApp } from '~/utils/firebase/app';
Expand All @@ -24,7 +25,7 @@ import {
import type { LinksFunction } from '@remix-run/node';
import type { FirebaseOptions } from 'firebase/app';

export async function clientLoader() {
export async function loader() {
return json(firebaseConfig());
}

Expand Down Expand Up @@ -67,9 +68,15 @@ export function Layout({ children }: { children: React.ReactNode }) {

export default function App() {
const config = useLoaderData<FirebaseOptions>();
const navigation = useNavigation();
initializeApp(config);

return <Outlet />;
return (
<>
<LoadingOverlay visible={navigation.state === 'loading'} />
<Outlet />
</>
);
}

export function HydrateFallback() {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_public._index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { replace } from '@remix-run/react';
import { replace } from '@remix-run/node';
import { LoadingScreen } from '~/components/screens/LoadingScreen';

export async function clientLoader() {
export async function loader() {
return replace('/books');
}

Expand Down
4 changes: 2 additions & 2 deletions app/routes/admin._index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { replace } from '@remix-run/react';
import { replace } from '@remix-run/node';
import { AdminRoot } from '~/components/pages/admin/AdminRoot';

export async function clientLoader() {
export async function loader() {
return replace('/admin/books');
}

Expand Down
15 changes: 5 additions & 10 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"hosting": {
"public": "build/client",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
"run": {
"serviceId": "remix-firebase-tutorial-sample",
"region": "asia-northeast1"
}
}
],
"predeploy": [
"rm -rf .firebase"
]
},
"functions": [
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"format": "prettier --write . && pnpm functions format && pnpm shared format",
"preview": "vite preview",
"typecheck": "tsc",
"deploy:hosting": "pnpm build && firebase deploy --except functions --project default",
"deploy:hosting": "firebase deploy --except functions --project default",
"deploy:cloudrun": "pnpm build && gcloud run deploy remix-firebase-tutorial-sample --project remix-fire-tutorial-sample --region asia-northeast1 --memory 1Gi --source .",
"deploy:functions": "pnpm functions deploy:default",
"deploy:rules": "firebase deploy --only firestore:rules,storage --project default",
"tsx": "tsx --env-file=scripts/.env"
"tsx": "tsx --env-file=scripts/.env",
"start": "remix-serve build/server/index.js"
},
"dependencies": {
"@local/shared": "workspace:^",
Expand All @@ -31,6 +33,7 @@
"@mantine/notifications": "^7.13.3",
"@remix-run/node": "^2.13.1",
"@remix-run/react": "^2.13.1",
"@remix-run/serve": "^2.13.1",
"@sonicgarden/react-fire-hooks": "^1.1.2",
"@tabler/icons-react": "^3.19.0",
"firebase": "^10.14.1",
Expand Down
Loading