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

Update website and samples to latest Remix with Vite #243

Open
wants to merge 8 commits into
base: update-dependencies
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
2 changes: 1 addition & 1 deletion apps/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"domain-functions": "^2.6.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-hook-form": "^7.51.3",
"react-hook-form": "^7.51.4",
"react-router-dom": "^6.23.0",
"remix-forms": "*",
"zod": "^3.23.6"
Expand Down
6 changes: 6 additions & 0 deletions apps/remix-1-7/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const path = require('path')

module.exports = {
extends: path.resolve(__dirname, '../../.eslintrc.base.js'),
rules: {},
}
6 changes: 6 additions & 0 deletions apps/remix-1-7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/.cache
/build
/public/build
.env
7 changes: 7 additions & 0 deletions apps/remix-1-7/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
public/build
dist
tsc
*.css
*.html
53 changes: 53 additions & 0 deletions apps/remix-1-7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)

## Development

From your terminal:

```sh
npm run dev
```

This starts your app in development mode, rebuilding assets on file changes.

## Deployment

First, build your app for production:

```sh
npm run build
```

Then run the app in production mode:

```sh
npm start
```

Now you'll need to pick a host to deploy it to.

### DIY

If you're familiar with deploying node applications, the built-in Remix app server is production-ready.

Make sure to deploy the output of `remix build`

- `build/`
- `public/build/`

### Using a Template

When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.

```sh
cd ..
# create a new project, and pick a pre-configured host
npx create-remix@latest
cd my-new-remix-app
# remove the new project's app (not the old one!)
rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app
```
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions apps/remix-1-7/app/formAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { json, redirect } from '@remix-run/node'
import { createFormAction } from 'remix-forms'

const formAction = createFormAction({ redirect, json })

export { formAction }
27 changes: 27 additions & 0 deletions apps/remix-1-7/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from '@remix-run/react'

export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
)
}
23 changes: 23 additions & 0 deletions apps/remix-1-7/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { makeDomainFunction } from 'domain-functions'
import type { ActionArgs } from '@remix-run/node'
import { z } from 'zod'
import { formAction } from '../formAction'
import { Form } from '../ui/form'

const schema = z.object({
firstName: z.string().min(1),
email: z.string().min(1).email(),
})

const mutation = makeDomainFunction(schema)(async (values) => values)

export function action({ request }: ActionArgs) {
return formAction({
request,
schema,
mutation,
successPath: '/success',
})
}

export default () => <Form schema={schema} />
1 change: 1 addition & 0 deletions apps/remix-1-7/app/routes/success.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => <h1>Success!</h1>
16 changes: 16 additions & 0 deletions apps/remix-1-7/app/ui/form.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createForm } from 'remix-forms'
import {
Form as RemixForm,
useActionData,
useSubmit,
useTransition as useNavigation,
} from '@remix-run/react'

const Form = createForm({
component: RemixForm,
useNavigation,
useSubmit,
useActionData,
})

export { Form }
34 changes: 34 additions & 0 deletions apps/remix-1-7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "remix-forms-remix-1-7",
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build",
"dev": "PORT=3002 remix dev",
"start": "remix-serve build",
"lint": "eslint . --max-warnings=0",
"prelint": "prettier --check .",
"tsc": "tsc"
},
"dependencies": {
"@remix-run/node": "1.7.4",
"@remix-run/react": "1.7.4",
"@remix-run/serve": "1.7.4",
"domain-functions": "^2.6.0",
"isbot": "^5.1.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"remix-forms": "*",
"zod": "^3.23.6"
},
"devDependencies": {
"@remix-run/dev": "1.7.4",
"@remix-run/eslint-config": "2.9.1",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"typescript": "~5.4.5"
},
"engines": {
"node": ">=14"
}
}
Binary file added apps/remix-1-7/public/favicon.ico
Binary file not shown.
15 changes: 15 additions & 0 deletions apps/remix-1-7/remix.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
ignoredRouteFiles: ['**/.*'],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
future: {
v2_errorBoundary: true,
v2_meta: true,
v2_normalizeFormMethod: true,
v2_routeConvention: true,
},
devServerPort: 8004,
}
2 changes: 2 additions & 0 deletions apps/remix-1-7/remix.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node" />
22 changes: 22 additions & 0 deletions apps/remix-1-7/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
"skipLibCheck": true,
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
43 changes: 27 additions & 16 deletions apps/web/app/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
import { compose, join, reject, isBoolean, isNil, flatten } from 'lodash/fp'
import type { HtmlMetaDescriptor } from '@remix-run/node'
import social from './social.png'
import type { MetaDescriptor } from '@remix-run/node'

const cx = (...args: unknown[]) =>
compose(join(' '), reject(isBoolean), reject(isNil), flatten)(args)
function cx(...args: unknown[]): string {
return args
.flat()
.filter((x) => typeof x === 'string')
.join(' ')
}

function pageTitle(title: string) {
return `${title} · Remix Forms`
}

const baseMeta = [
{ property: 'author', content: 'Seasoned' },
{ property: 'og:type', content: 'website' },
{ property: 'og:image', content: social },
{ property: 'og:site_name', content: 'Remix Forms' },
]

function metaTags({
title: rawTitle,
description,
...otherTags
}: Record<string, string>) {
}: {
title: string
description?: string
}): MetaDescriptor[] {
const title = rawTitle ? pageTitle(rawTitle) : null
const titleTags = title ? { title, 'og:title': title } : {}
const titleTags: MetaDescriptor[] = title
? [{ title }, { property: 'og:title', content: title }]
: []

const descriptionTags = description
? { description, 'og:description': description }
: {}
const descriptionTags: MetaDescriptor[] = description
? [{ description }, { property: 'og:description', content: description }]
: []

return {
...titleTags,
...descriptionTags,
...otherTags,
} as HtmlMetaDescriptor
return [...titleTags, ...descriptionTags, ...baseMeta]
}

export { cx, pageTitle, metaTags }
export { cx, pageTitle, metaTags, baseMeta }
Loading
Loading