-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e55d64b
Showing
17 changed files
with
2,325 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# フロントエンド入門ワークショップ React 編 | ||
|
||
## 前準備 | ||
|
||
### 環境 | ||
|
||
本ワークショップは WSL2 または macOS 環境を前提とします | ||
|
||
### Node.js のインストール | ||
|
||
直接インストールしてもよいですが、これを機に [mise](https://mise.jdx.dev/getting-started.html) のようなバージョンマネージャーを導入することをお勧めします。 | ||
|
||
Node.js 最新 LTS の 20.x 系が使えることを確認してください。 | ||
|
||
```shell | ||
$ node -v | ||
v20.11.1 | ||
``` | ||
|
||
パッケージマネージャーは pnpm を利用します。 | ||
(様々なプロジェクトで pnpm を利用しているため) | ||
|
||
```shell | ||
$ corepack enable pnpm | ||
``` | ||
|
||
|
||
## プロジェクトの作成 | ||
|
||
```shell | ||
$ pnpm create vite frontend-workshop-react --template react-ts | ||
../Library/pnpm/store/v3/tmp/dlx-13453 | +1 + | ||
../Library/pnpm/store/v3/tmp/dlx-13453 | Progress: resolved 1, reused 1, downloaded 0, added 1, done | ||
|
||
Scaffolding project in /Users/ondat/workspace/frontend-workshop-react... | ||
|
||
Done. Now run: | ||
|
||
cd frontend-workshop-react | ||
pnpm install | ||
pnpm run dev | ||
|
||
$ cd frontend-workshop-react | ||
|
||
$ pnpm install | ||
Downloading registry.npmjs.org/typescript/5.4.3: 5.82 MB/5.82 MB, done | ||
Packages: +211 | ||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
Progress: resolved 245, reused 175, downloaded 36, added 211, done | ||
node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, done in 231ms | ||
|
||
dependencies: | ||
+ react 18.2.0 | ||
+ react-dom 18.2.0 | ||
|
||
devDependencies: | ||
+ @types/react 18.2.69 | ||
+ @types/react-dom 18.2.22 | ||
+ @typescript-eslint/eslint-plugin 7.3.1 | ||
+ @typescript-eslint/parser 7.3.1 | ||
+ @vitejs/plugin-react 4.2.1 | ||
+ eslint 8.57.0 | ||
+ eslint-plugin-react-hooks 4.6.0 | ||
+ eslint-plugin-react-refresh 0.4.6 | ||
+ typescript 5.4.3 | ||
+ vite 5.2.6 | ||
|
||
Done in 18.6s | ||
``` | ||
|
||
## 動作確認 | ||
|
||
```shell | ||
$ pnpm dev | ||
|
||
VITE v5.2.6 ready in 113 ms | ||
|
||
➜ Local: http://localhost:5173/ | ||
➜ Network: use --host to expose | ||
➜ press h + enter to show help | ||
``` | ||
|
||
ブラウザで `http://localhost:5173/` を開いて、以下の画面が表示されれば成功です。 | ||
|
||
![vite-react.png](img.png) | ||
|
||
|
||
## デプロイ | ||
|
||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "frontend-workshop-react", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.66", | ||
"@types/react-dom": "^18.2.22", | ||
"@typescript-eslint/eslint-plugin": "^7.2.0", | ||
"@typescript-eslint/parser": "^7.2.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.6", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.2.0" | ||
} | ||
} |
Oops, something went wrong.