Init: With Remix Vite Template

初始化项目
This commit is contained in:
奇趣保罗 2023-11-04 21:33:23 +08:00
commit 52cf50f4b4
10 changed files with 6551 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
node_modules
/.cache
/build
/public/build
.env

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# templates/unstable-vite
⚠️ Remix support for Vite is unstable and not recommended for production.
📖 See the [Remix Vite docs][remix-vite-docs] for details on supported features.
## Setup
```shellscript
npx create-remix@latest --template remix-run/remix/templates/unstable-vite
```
## Run
Spin up the Vite dev server:
```shellscript
npm run dev
```
Or build your app for production and run it:
```shellscript
npm run build
npm run start
```
[remix-vite-docs]: https://remix.run/docs/en/main/future/vite

33
app/root.tsx Normal file
View File

@ -0,0 +1,33 @@
import { cssBundleHref } from "@remix-run/css-bundle";
import type { LinksFunction } from "@remix-run/node";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];
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 />
<LiveReload />
<Scripts />
</body>
</html>
);
}

41
app/routes/_index.tsx Normal file
View File

@ -0,0 +1,41 @@
import type { MetaFunction } from "@remix-run/node";
export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/blog"
rel="noreferrer"
>
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/jokes"
rel="noreferrer"
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
Remix Docs
</a>
</li>
</ul>
</div>
);
}

2
env.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/// <reference types="@remix-run/node" />
/// <reference types="vite/client" />

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "vite-remix-test",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "vite build && vite build --ssr",
"dev": "vite dev",
"start": "remix-serve ./build/index.js",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/css-bundle": "^2.2.0",
"@remix-run/node": "^2.2.0",
"@remix-run/react": "^2.2.0",
"@remix-run/serve": "^2.2.0",
"isbot": "^3.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.2.0",
"@remix-run/eslint-config": "^2.2.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"eslint": "^8.38.0",
"typescript": "^5.1.6",
"vite": "^4.5.0",
"vite-tsconfig-paths": "^4.2.1"
},
"engines": {
"node": ">=18.0.0"
}
}

6377
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

23
tsconfig.json Normal file
View File

@ -0,0 +1,23 @@
{
"include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}

7
vite.config.ts Normal file
View File

@ -0,0 +1,7 @@
import { unstable_vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({
plugins: [remix(), tsconfigPaths()],
});