Skip to content

Commit bfe1121

Browse files
chore: add vite-7 example
1 parent 587f506 commit bfe1121

File tree

14 files changed

+5444
-3901
lines changed

14 files changed

+5444
-3901
lines changed
79.3 KB
Binary file not shown.
79.3 KB
Binary file not shown.
79 KB
Binary file not shown.
79.3 KB
Binary file not shown.

examples/vite-7/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Vite App</title>
7+
</head>
8+
<body>
9+
<h1>Hello Vite!</h1>
10+
<h2>I'm using a local font !</h2>
11+
<div class="fontsource-abeezee">I'm a ABeeZee fontsource</div>
12+
<div class="fontsource-truculenta">I'm a Truculenta fontsource</div>
13+
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
14+
<script type="module" src="/main.ts"></script>
15+
</body>
16+
</html>

examples/vite-7/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import 'unfonts.css'
2+
import './style.css'

examples/vite-7/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "vite-7",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"preview": "vite preview"
9+
},
10+
"devDependencies": {
11+
"@fontsource/abeezee": "^5.1.0",
12+
"@fontsource/truculenta": "^5.1.0",
13+
"unplugin-fonts": "workspace:*",
14+
"vite": "^7.0.0"
15+
}
16+
}

examples/vite-7/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
body {
2+
font-family: "Crimson Pro", Avenir, Helvetica, Arial, sans-serif;
3+
-webkit-font-smoothing: antialiased;
4+
-moz-osx-font-smoothing: grayscale;
5+
text-align: center;
6+
color: #2c3e50;
7+
margin-top: 60px;
8+
}
9+
10+
a {
11+
font-family: "Open Sans", Avenir, Helvetica, Arial, sans-serif;
12+
}
13+
14+
h2 {
15+
font-family: "Dancing Script", sans-serif;
16+
font-size: 3rem;
17+
font-weight: 600;
18+
}
19+
20+
21+
.fontsource-abeezee {
22+
font-family: "ABeeZee", sans-serif;
23+
}
24+
25+
.fontsource-truculenta {
26+
font-family: "Truculenta", sans-serif;
27+
}

examples/vite-7/vite.config.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { defineConfig } from 'vite'
2+
import Unfonts from '../../src/vite'
3+
4+
export default defineConfig({
5+
plugins: [
6+
Unfonts({
7+
google: {
8+
families: ['Crimson Pro', 'Open Sans', 'Material+Icons'],
9+
},
10+
11+
custom: {
12+
display: 'swap',
13+
families: {
14+
'Dancing Script': {
15+
src: './assets/fonts/DancingScript*',
16+
transform(font) {
17+
if (font.basename === 'DancingScript-Bold')
18+
font.weight = 700
19+
20+
return font
21+
},
22+
},
23+
},
24+
},
25+
26+
fontsource: {
27+
families: [
28+
{
29+
name: 'ABeeZee',
30+
weights: [400],
31+
styles: ['italic'],
32+
},
33+
{
34+
name: 'Truculenta',
35+
weights: [400, 700],
36+
},
37+
],
38+
},
39+
}),
40+
],
41+
})

examples/vitepress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vitepress",
3-
"private": true,
43
"type": "module",
4+
"private": true,
55
"scripts": {
66
"dev": "vitepress dev",
77
"start": "vitepress dev",

0 commit comments

Comments
 (0)