Skip to content

Commit 93736ec

Browse files
authored
Merge pull request #16 from raduwen/migrate-vite
migrate vite v2
2 parents 5cc365c + a05d462 commit 93736ec

File tree

11 files changed

+492
-1311
lines changed

11 files changed

+492
-1311
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
node_modules
22
.cache
3-
.next
43
*.log
5-
6-
.env.local
4+
dist
5+
dist-ssr
6+
*.local

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite App</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
"node": "14.x"
88
},
99
"scripts": {
10-
"dev": "next dev",
11-
"build": "next build",
12-
"start": "next start",
10+
"dev": "vite",
11+
"build": "tsc && vite build",
12+
"serve": "vite preview",
1313
"firebase:emulator:start": "firebase emulators:start"
1414
},
1515
"dependencies": {
1616
"firebase": "^8.6.2",
17-
"next": "^10.2.3",
1817
"react": "^17.0.2",
1918
"react-dom": "^17.0.2"
2019
},
@@ -23,7 +22,10 @@
2322
"@types/node": "^14.17.1",
2423
"@types/react": "^17.0.2",
2524
"@types/react-dom": "^17.0.2",
25+
"@vitejs/plugin-react-refresh": "^1.3.1",
2626
"firebase-tools": "^9.12.0",
27-
"typescript": "^4.1.5"
27+
"typescript": "^4.3.2",
28+
"vite": "^2.4.4",
29+
"vite-tsconfig-paths": "^3.3.13"
2830
}
2931
}

components/TextWidget/index.tsx renamed to src/components/TextWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VFC, CSSProperties } from 'react';
1+
import React, { VFC, CSSProperties } from 'react';
22

33
type Position = {
44
top?: number; // px

components/TimeWidget/index.tsx renamed to src/components/TimeWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { CSSProperties } from 'react'
1+
import React, { CSSProperties } from 'react';
22

33
interface TimeWidgetProps {
44
size: number;
File renamed without changes.

src/main.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
4+
import '@/global.css';
5+
import { TextWidget } from '@/components/TextWidget';
6+
import { TimeWidget } from '@/components/TimeWidget';
7+
8+
const Widgets = {
9+
'text': TextWidget,
10+
'time': TimeWidget,
11+
};
12+
13+
const App = () => {
14+
const text = `オレオレOBSウィジェットの整理`;
15+
16+
const widgets = [
17+
{ name: 'text', props: { text: text } },
18+
{ name: 'time', props: { size: 30 } },
19+
];
20+
21+
return (
22+
<div>
23+
{widgets.map((widget) => {
24+
const Widget = Widgets[widget.name];
25+
return <Widget {...widget.props} />
26+
})}
27+
</div>
28+
);
29+
};
30+
31+
render(
32+
<React.StrictMode>
33+
<App />
34+
</React.StrictMode>,
35+
document.getElementById('root')
36+
);

src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
"jsx": "preserve",
2020
"baseUrl": ".",
2121
"paths": {
22-
"@/*": ["*"]
22+
"@/*": ["./src/*"]
2323
}
2424
},
2525
"include": [
26-
"next-env.d.ts",
2726
"**/*.ts",
2827
"**/*.tsx"
2928
],

vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'vite';
2+
import reactRefresh from '@vitejs/plugin-react-refresh';
3+
import tsconfigPaths from 'vite-tsconfig-paths';
4+
5+
// https://vitejs.dev/config/
6+
export default defineConfig({
7+
plugins: [tsconfigPaths(), reactRefresh()]
8+
});

0 commit comments

Comments
 (0)