Skip to content

Commit 2a4fb03

Browse files
authored
refactor(sass): Switch to V2 + Vite (#491)
1 parent 83b27f2 commit 2a4fb03

File tree

12 files changed

+190
-77
lines changed

12 files changed

+190
-77
lines changed

sass/.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+
};

sass/.eslintrc.js

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

sass/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ node_modules
22

33
/.cache
44
/build
5-
/public/build
65
.env
7-
8-
/app/styles

sass/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Open this example on [CodeSandbox](https://codesandbox.com):
1010

1111
## Example
1212

13-
The main thing to note here is that `npm run dev` will run the sass compiler, and remix in the same tab uisng `npm-run-all`. When building with `npm run build`, we'll have `npm-run-all` run the sass build and minify the output and run `remix build`.
13+
Nothing much going on here, sass/scss files imports work out of the box in Vite.
1414

1515
## Related Links
1616

1717
- [Sass](https://sass-lang.com)
18-
- [npm-run-all](https://www.npmjs.com/package/npm-run-all)
18+
- [Vite CSS Pre-processors](https://vitejs.dev/guide/features#css-pre-processors)

sass/app/root.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
import type { LinksFunction, MetaFunction } from "@remix-run/node";
1+
import type { LinksFunction } from "@remix-run/node";
22
import {
33
Links,
4-
LiveReload,
54
Meta,
65
Outlet,
76
Scripts,
87
ScrollRestoration,
98
} from "@remix-run/react";
109

11-
import globalStyles from "~/styles/global.css";
10+
import globalStyles from "~/styles/global.scss?url";
1211

1312
export const links: LinksFunction = () => [
1413
{ rel: "stylesheet", href: globalStyles },
1514
];
1615

17-
export const meta: MetaFunction = () => ({
18-
charset: "utf-8",
19-
title: "New Remix App",
20-
viewport: "width=device-width,initial-scale=1",
21-
});
22-
23-
export default function App() {
16+
export function Layout({ children }: { children: React.ReactNode }) {
2417
return (
2518
<html lang="en">
2619
<head>
20+
<meta charSet="utf-8" />
21+
<meta name="viewport" content="width=device-width, initial-scale=1" />
2722
<Meta />
2823
<Links />
2924
</head>
3025
<body>
31-
<Outlet />
26+
{children}
3227
<ScrollRestoration />
3328
<Scripts />
34-
<LiveReload />
3529
</body>
3630
</html>
3731
);
3832
}
33+
34+
export default function App() {
35+
return <Outlet />;
36+
}

sass/styles/global.scss renamed to sass/app/styles/global.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$font-stack: system-ui, sans-serif;
2-
$primary-color: #333;
2+
$primary-color: #D90000;
33
$line-height: 1.8;
44

55
:root {

sass/package.json

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
{
2+
"name": "template",
23
"private": true,
34
"sideEffects": false,
5+
"type": "module",
46
"scripts": {
5-
"build": "run-s \"build:*\"",
6-
"build:css": "npm run generate:css -- --style=compressed",
7-
"build:remix": "remix build",
8-
"dev": "run-p \"dev:*\"",
9-
"dev:css": "npm run generate:css -- --watch",
10-
"dev:remix": "remix dev",
11-
"generate:css": "sass styles/:app/styles/",
12-
"start": "remix-serve build",
7+
"build": "remix vite:build",
8+
"dev": "remix vite:dev",
9+
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
10+
"start": "remix-serve ./build/server/index.js",
1311
"typecheck": "tsc"
1412
},
1513
"dependencies": {
16-
"@remix-run/node": "^1.19.3",
17-
"@remix-run/react": "^1.19.3",
18-
"@remix-run/serve": "^1.19.3",
19-
"isbot": "^3.6.5",
14+
"@remix-run/node": "^2.9.2",
15+
"@remix-run/react": "^2.9.2",
16+
"@remix-run/serve": "^2.9.2",
17+
"isbot": "^4.1.0",
2018
"react": "^18.2.0",
2119
"react-dom": "^18.2.0"
2220
},
2321
"devDependencies": {
24-
"@remix-run/dev": "^1.19.3",
25-
"@remix-run/eslint-config": "^1.19.3",
26-
"@types/react": "^18.0.25",
27-
"@types/react-dom": "^18.0.8",
28-
"eslint": "^8.27.0",
29-
"npm-run-all": "4.1.5",
30-
"sass": "1.49.9",
31-
"typescript": "^4.8.4"
22+
"@remix-run/dev": "^2.9.2",
23+
"@types/react": "^18.2.20",
24+
"@types/react-dom": "^18.2.7",
25+
"@typescript-eslint/eslint-plugin": "^6.7.4",
26+
"@typescript-eslint/parser": "^6.7.4",
27+
"eslint": "^8.38.0",
28+
"eslint-import-resolver-typescript": "^3.6.1",
29+
"eslint-plugin-import": "^2.28.1",
30+
"eslint-plugin-jsx-a11y": "^6.7.1",
31+
"eslint-plugin-react": "^7.33.2",
32+
"eslint-plugin-react-hooks": "^4.6.0",
33+
"sass": "^1.77.2",
34+
"typescript": "^5.1.6",
35+
"vite": "^5.1.0",
36+
"vite-tsconfig-paths": "^4.2.1"
3237
},
3338
"engines": {
34-
"node": ">=14.0.0"
39+
"node": ">=20.0.0"
3540
}
36-
}
41+
}

sass/remix.config.js

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

sass/remix.env.d.ts

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

sass/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
}

0 commit comments

Comments
 (0)