Skip to content

Commit 36f8275

Browse files
authored
build: configuration update (#41)
- to be able to build the project both on GitHub and Netlify, base config property in vite must be read from the environment - updated the script to use the variable, updated vite config to use the variable also - renamed configuration files for ESLint and Prettier to their .json counterparts - added eslint-plugin-jsonc and eslint-plugin-toml andenabled linting for json and toml files, hidden files now linted by default in configuration - removed types from tsconfig.json and added vite-env.d.ts with vite/client typings
1 parent 624602b commit 36f8275

13 files changed

+110
-26
lines changed

.eslintrc renamed to .eslintrc.json

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"root": true,
3-
"ignorePatterns": ["dist/*"],
3+
"ignorePatterns": ["dist", "!**/.*"],
44
"overrides": [
55
{
6-
"files": ["*.ts", "*.tsx"],
6+
"files": ["*.{ts,tsx}"],
77
"parser": "@typescript-eslint/parser",
88
"extends": [
99
"eslint:recommended",
@@ -17,11 +17,12 @@
1717
],
1818
"env": {
1919
"browser": true,
20-
"es2022": true
20+
"node": true
2121
},
2222
"parserOptions": {
2323
"sourceType": "module",
2424
"project": "tsconfig.json",
25+
"ecmaVersion": "latest",
2526
"ecmaFeatures": {
2627
"jsx": true
2728
}
@@ -30,8 +31,21 @@
3031
"import/resolver": {
3132
"typescript": {}
3233
},
33-
"import/core-modules": [ "uno.css" ]
34+
"import/core-modules": ["uno.css"]
3435
}
36+
},
37+
{
38+
"files": ["*.json"],
39+
"extends": [
40+
"eslint:recommended",
41+
"plugin:jsonc/recommended-with-json",
42+
"plugin:jsonc/prettier",
43+
"plugin:prettier/recommended"
44+
]
45+
},
46+
{
47+
"files": ["*.toml"],
48+
"extends": ["eslint:recommended", "plugin:toml/standard"]
3549
}
3650
]
3751
}

.github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
- main
66
pull_request:
77

8+
env:
9+
BASE: /${{ github.event.repository.name }}/
10+
811
jobs:
912
build-and-deploy:
1013
runs-on: ubuntu-latest
File renamed without changes.

.vscode/settings.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"editor.codeActionsOnSave": {
3-
"source.fixAll.eslint": true,
3+
"source.fixAll.eslint": true
44
},
5-
"files.associations": {
6-
".eslintrc": "json",
7-
".prettierrc": "json"
8-
}
5+
"eslint.validate": ["typescript", "typescriptreact", "json", "jsonc", "toml"]
96
}

index.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<!DOCTYPE html>
2-
<html lang="en" class="h-full">
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
56
<title>Solid Clock</title>
67
<link rel="icon" type="image/svg+xml" href="/logo.svg">
78
</head>
8-
<body class="h-full m-0">
9-
<div id="root" class="h-full"></div>
9+
<body class="m-0">
10+
<div id="root"></div>
1011
<script type="module" src="/src/index.tsx"></script>
1112
</body>
1213
</html>

netlify.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build]
2+
command = "pnpm build"
3+
publish = "dist"
4+
5+
[build.environment]
6+
NODE_VERSION = "18"

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
"start": "vite"
1212
},
1313
"devDependencies": {
14+
"@types/node": "^18.11.9",
1415
"@typescript-eslint/eslint-plugin": "5.41.0",
1516
"@typescript-eslint/parser": "5.41.0",
1617
"eslint": "8.26.0",
1718
"eslint-config-prettier": "8.5.0",
1819
"eslint-import-resolver-typescript": "3.5.2",
1920
"eslint-plugin-import": "2.26.0",
21+
"eslint-plugin-jsonc": "^2.5.0",
2022
"eslint-plugin-jsx-a11y": "6.6.1",
2123
"eslint-plugin-prettier": "4.2.1",
2224
"eslint-plugin-solid": "0.7.4",
25+
"eslint-plugin-toml": "^0.3.1",
2326
"prettier": "2.7.1",
2427
"typescript": "4.8.4",
2528
"unocss": "0.46.1",

pnpm-lock.yaml

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ClockFace.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ClockFace = () => {
2323
onCleanup(() => cancelAnimationFrame(frame));
2424

2525
return (
26-
<div class="flex items-center justify-center h-full @dark:bg-neutral-700">
26+
<div class="flex items-center justify-center h-screen @dark:bg-neutral-700">
2727
<svg viewBox="0 0 200 200" class="h-95vmin">
2828
<g class="translate-100px">
2929
<circle

src/ClockHand.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type ClockHandProps = {
77
} & JSX.LineSVGAttributes<SVGLineElement>;
88

99
export const ClockHand = (props: ClockHandProps) => {
10-
const props_ = mergeProps({ length: 0, limit: 94, class: '' }, props);
10+
const props_ = mergeProps({ length: 0, limit: 94 }, props);
1111
const [local, rest] = splitProps(props_, ['length', 'limit', 'stationary']);
1212

1313
return (

src/vite-env.d.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
readonly BASE?: string;
5+
}
6+
7+
interface ImportMeta {
8+
readonly env: ImportMetaEnv;
9+
}

tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"esModuleInterop": true,
88
"jsx": "preserve",
99
"jsxImportSource": "solid-js",
10-
"types": ["vite/client"],
1110
"noEmit": true,
1211
"isolatedModules": true,
1312
"baseUrl": "src",

vite.config.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import { defineConfig } from 'vite';
1+
import { defineConfig, loadEnv, type ConfigEnv } from 'vite';
22
import solid from 'vite-plugin-solid';
33
import uno from 'unocss/vite';
44
import tsconfigPaths from 'vite-tsconfig-paths';
55

6-
export default defineConfig({
7-
base: '/solid-clock/',
8-
plugins: [solid(), uno(), tsconfigPaths()],
9-
optimizeDeps: {
10-
disabled: false,
11-
},
12-
build: {
13-
commonjsOptions: { include: [] },
14-
},
15-
});
6+
export default ({ mode }: ConfigEnv) =>
7+
defineConfig({
8+
base: loadEnv(mode, process.cwd(), '')['BASE'],
9+
plugins: [solid(), uno(), tsconfigPaths()],
10+
});

0 commit comments

Comments
 (0)