Skip to content

Commit 93afe11

Browse files
committed
⚒️ Config TailwindCSS with Preact & Vitejs.
1 parent c39ad9f commit 93afe11

File tree

9 files changed

+33
-112
lines changed

9 files changed

+33
-112
lines changed

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"postcss": "8.4.16",
1818
"tailwindcss": "3.1.8",
1919
"typescript": "4.8.2",
20+
"vite-tsconfig-paths": "3.5.0",
2021
"vite": "3.1.0"
2122
}
2223
}

website/public/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

website/src/app.tsx

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
1-
import { useState } from 'preact/hooks'
2-
import preactLogo from './assets/preact.svg'
3-
import './app.css'
1+
import { useState } from 'preact/hooks';
42

53
export function App() {
6-
const [count, setCount] = useState(0)
4+
const [count, setCount] = useState(0);
75

86
return (
9-
<>
10-
<div>
11-
<a href="https://vitejs.dev" target="_blank">
12-
<img src="/vite.svg" class="logo" alt="Vite logo" />
13-
</a>
14-
<a href="https://preactjs.com" target="_blank">
15-
<img src={preactLogo} class="logo preact" alt="Preact logo" />
16-
</a>
17-
</div>
18-
<h1>Vite + Preact</h1>
19-
<div class="card">
20-
<button onClick={() => setCount((count) => count + 1)}>
21-
count is {count}
22-
</button>
23-
<p>
24-
Edit <code>src/app.tsx</code> and save to test HMR
25-
</p>
26-
</div>
27-
<p class="read-the-docs">
28-
Click on the Vite and Preact logos to learn more
29-
</p>
30-
</>
31-
)
7+
<div>
8+
<button onClick={() => setCount((count) => count + 1)}>
9+
count is {count}
10+
</button>
11+
<h1 className="text-3xl font-bold underline">Hello world!</h1>
12+
</div>
13+
);
3214
}

website/src/assets/preact.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

website/src/index.css

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

website/src/main.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { render } from 'preact'
2-
import { App } from './app'
3-
import './index.css'
1+
import { render } from 'preact';
42

5-
render(<App />, document.getElementById('app') as HTMLElement)
3+
// App =>
4+
import { App } from '@/app';
5+
6+
// Styles =>
7+
import '@/styles/globals.css';
8+
9+
render(<App />, document.getElementById('app') as HTMLElement);

website/src/pages/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React from 'preact';
2-
31
const Home = () => {
4-
return <div>index</div>;
2+
return (
3+
<div>
4+
<h1>page</h1>
5+
</div>
6+
);
57
};
68

79
export default Home;

website/src/styles/globals.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

website/vite.config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { defineConfig } from 'vite'
2-
import preact from '@preact/preset-vite'
1+
import { defineConfig } from 'vite';
2+
import preact from '@preact/preset-vite';
3+
4+
// Plugins =>
5+
import tsconfigPaths from 'vite-tsconfig-paths';
36

4-
// https://vitejs.dev/config/
57
export default defineConfig({
6-
plugins: [preact()]
7-
})
8+
plugins: [preact(), tsconfigPaths()]
9+
});

0 commit comments

Comments
 (0)