Skip to content

Commit b257b6c

Browse files
refactor(vanilla-extract): Switch to V2 + Vite (#500)
Co-authored-by: Mark Dalgleish <[email protected]>
1 parent a6c5c8f commit b257b6c

File tree

9 files changed

+153
-56
lines changed

9 files changed

+153
-56
lines changed

vanilla-extract/.eslintrc.cjs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* This is intended to be a basic starting point for linting in your app.
3+
* It relies on recommended configs out of the box for simplicity, but you can
4+
* and should modify this configuration to best suit your team's needs.
5+
*/
6+
7+
/** @type {import('eslint').Linter.Config} */
8+
module.exports = {
9+
root: true,
10+
parserOptions: {
11+
ecmaVersion: "latest",
12+
sourceType: "module",
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
env: {
18+
browser: true,
19+
commonjs: true,
20+
es6: true,
21+
},
22+
ignorePatterns: ["!**/.server", "!**/.client"],
23+
24+
// Base config
25+
extends: ["eslint:recommended"],
26+
27+
overrides: [
28+
// React
29+
{
30+
files: ["**/*.{js,jsx,ts,tsx}"],
31+
plugins: ["react", "jsx-a11y"],
32+
extends: [
33+
"plugin:react/recommended",
34+
"plugin:react/jsx-runtime",
35+
"plugin:react-hooks/recommended",
36+
"plugin:jsx-a11y/recommended",
37+
],
38+
settings: {
39+
react: {
40+
version: "detect",
41+
},
42+
formComponents: ["Form"],
43+
linkComponents: [
44+
{ name: "Link", linkAttribute: "to" },
45+
{ name: "NavLink", linkAttribute: "to" },
46+
],
47+
"import/resolver": {
48+
typescript: {},
49+
},
50+
},
51+
},
52+
53+
// Typescript
54+
{
55+
files: ["**/*.{ts,tsx}"],
56+
plugins: ["@typescript-eslint", "import"],
57+
parser: "@typescript-eslint/parser",
58+
settings: {
59+
"import/internal-regex": "^~/",
60+
"import/resolver": {
61+
node: {
62+
extensions: [".ts", ".tsx"],
63+
},
64+
typescript: {
65+
alwaysTryTypes: true,
66+
},
67+
},
68+
},
69+
extends: [
70+
"plugin:@typescript-eslint/recommended",
71+
"plugin:import/recommended",
72+
"plugin:import/typescript",
73+
],
74+
},
75+
76+
// Node
77+
{
78+
files: [".eslintrc.cjs"],
79+
env: {
80+
node: true,
81+
},
82+
},
83+
],
84+
};

vanilla-extract/.eslintrc.js

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

vanilla-extract/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ node_modules
22

33
/.cache
44
/build
5-
/public/build
65
.env

vanilla-extract/app/root.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
import "~/global.css";
2-
3-
import { cssBundleHref } from "@remix-run/css-bundle";
4-
import type { LinksFunction, MetaFunction } from "@remix-run/node";
51
import {
62
Links,
7-
LiveReload,
83
Meta,
94
Outlet,
105
Scripts,
116
ScrollRestoration,
127
} from "@remix-run/react";
138

14-
export const links: LinksFunction = () =>
15-
cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : [];
16-
17-
export const meta: MetaFunction = () => ({
18-
charset: "utf-8",
19-
title: "New Remix App",
20-
viewport: "width=device-width,initial-scale=1",
21-
});
9+
import "./global.css";
2210

23-
export default function App() {
11+
export function Layout({ children }: { children: React.ReactNode }) {
2412
return (
2513
<html lang="en">
2614
<head>
15+
<meta charSet="utf-8" />
16+
<meta name="viewport" content="width=device-width, initial-scale=1" />
2717
<Meta />
2818
<Links />
2919
</head>
3020
<body>
31-
<Outlet />
21+
{children}
3222
<ScrollRestoration />
3323
<Scripts />
34-
<LiveReload />
3524
</body>
3625
</html>
3726
);
3827
}
28+
29+
export default function App() {
30+
return <Outlet />;
31+
}

vanilla-extract/package.json

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
{
2+
"name": "template",
23
"private": true,
34
"sideEffects": [
4-
"*.css.ts"
5+
"**/*.css.ts"
56
],
7+
"type": "module",
68
"scripts": {
7-
"build": "remix build",
8-
"dev": "remix dev",
9-
"start": "remix-serve build",
9+
"build": "remix vite:build",
10+
"dev": "remix vite:dev",
11+
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
12+
"start": "remix-serve ./build/server/index.js",
1013
"typecheck": "tsc"
1114
},
1215
"dependencies": {
13-
"@remix-run/css-bundle": "^1.19.3",
14-
"@remix-run/node": "^1.19.3",
15-
"@remix-run/react": "^1.19.3",
16-
"@remix-run/serve": "^1.19.3",
16+
"@remix-run/node": "^2.9.2",
17+
"@remix-run/react": "^2.9.2",
18+
"@remix-run/serve": "^2.9.2",
1719
"@vanilla-extract/css": "^1.11.0",
1820
"@vanilla-extract/sprinkles": "^1.5.2",
1921
"clsx": "^1.2.1",
20-
"isbot": "^3.6.5",
22+
"isbot": "^4.1.0",
2123
"react": "^18.2.0",
2224
"react-dom": "^18.2.0"
2325
},
2426
"devDependencies": {
25-
"@remix-run/dev": "^1.19.3",
26-
"@remix-run/eslint-config": "^1.19.3",
27-
"@types/react": "^18.0.25",
28-
"@types/react-dom": "^18.0.8",
29-
"eslint": "^8.27.0",
30-
"typescript": "^4.8.4"
27+
"@remix-run/dev": "^2.9.2",
28+
"@types/react": "^18.2.20",
29+
"@types/react-dom": "^18.2.7",
30+
"@typescript-eslint/eslint-plugin": "^6.7.4",
31+
"@typescript-eslint/parser": "^6.7.4",
32+
"@vanilla-extract/vite-plugin": "^4.0.10",
33+
"eslint": "^8.38.0",
34+
"eslint-import-resolver-typescript": "^3.6.1",
35+
"eslint-plugin-import": "^2.28.1",
36+
"eslint-plugin-jsx-a11y": "^6.7.1",
37+
"eslint-plugin-react": "^7.33.2",
38+
"eslint-plugin-react-hooks": "^4.6.0",
39+
"typescript": "^5.1.6",
40+
"vite": "^5.1.0",
41+
"vite-tsconfig-paths": "^4.2.1"
3142
},
3243
"engines": {
33-
"node": ">=14.0.0"
44+
"node": ">=20.0.0"
3445
}
3546
}

vanilla-extract/remix.config.js

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

vanilla-extract/remix.env.d.ts

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

vanilla-extract/tsconfig.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
{
2-
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
2+
"include": [
3+
"**/*.ts",
4+
"**/*.tsx",
5+
"**/.server/**/*.ts",
6+
"**/.server/**/*.tsx",
7+
"**/.client/**/*.ts",
8+
"**/.client/**/*.tsx"
9+
],
310
"compilerOptions": {
4-
"lib": ["DOM", "DOM.Iterable", "ES2019"],
11+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
12+
"types": ["@remix-run/node", "vite/client"],
513
"isolatedModules": true,
614
"esModuleInterop": true,
715
"jsx": "react-jsx",
8-
"moduleResolution": "node",
16+
"module": "ESNext",
17+
"moduleResolution": "Bundler",
918
"resolveJsonModule": true,
10-
"target": "ES2019",
19+
"target": "ES2022",
1120
"strict": true,
1221
"allowJs": true,
22+
"skipLibCheck": true,
1323
"forceConsistentCasingInFileNames": true,
1424
"baseUrl": ".",
1525
"paths": {
1626
"~/*": ["./app/*"]
1727
},
1828

19-
// Remix takes care of building everything in `remix build`.
29+
// Vite takes care of building everything, not tsc.
2030
"noEmit": true
2131
}
2232
}

vanilla-extract/vite.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { vitePlugin as remix } from "@remix-run/dev";
2+
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
3+
import { defineConfig } from "vite";
4+
import tsconfigPaths from "vite-tsconfig-paths";
5+
6+
export default defineConfig({
7+
plugins: [
8+
remix({
9+
future: {
10+
v3_fetcherPersist: true,
11+
v3_relativeSplatPath: true,
12+
v3_throwAbortReason: true,
13+
},
14+
}),
15+
tsconfigPaths(),
16+
vanillaExtractPlugin(),
17+
],
18+
});

0 commit comments

Comments
 (0)