Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 25354d1

Browse files
committed
Vite + Vue 3
1 parent e932875 commit 25354d1

34 files changed

+1890
-63
lines changed

.github/workflows/node.js.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: actions/setup-node@v3
4545
with:
4646
node-version: ${{ matrix.node-version }}
47-
cache: "pnpm"
47+
cache: pnpm
4848
- name: Install dependencies
4949
run: |
5050
pnpm install
@@ -56,4 +56,5 @@ jobs:
5656
- name: Test with Jest
5757
run: |
5858
pnpm run test --ci --coverage
59+
cd admin && pnpm run test:unit && cd ..
5960
codecov

admin/.eslintrc.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-env node */
2+
require("@rushstack/eslint-patch/modern-module-resolution");
3+
4+
module.exports = {
5+
root: true,
6+
extends: [
7+
"plugin:vue/vue3-essential",
8+
"eslint:recommended",
9+
"@vue/eslint-config-typescript/recommended",
10+
"@vue/eslint-config-prettier",
11+
],
12+
env: {
13+
"vue/setup-compiler-macros": true,
14+
},
15+
rules: { "prettier/prettier": "error" },
16+
};

admin/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
19+
20+
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
23+
.idea
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?

admin/.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
3+
}

admin/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# admin
2+
3+
This template should help get you started developing with Vue 3 in Vite.
4+
5+
## Recommended IDE Setup
6+
7+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
8+
9+
## Type Support for `.vue` Imports in TS
10+
11+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
12+
13+
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
14+
15+
1. Disable the built-in TypeScript Extension
16+
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17+
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18+
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
19+
20+
## Customize configuration
21+
22+
See [Vite Configuration Reference](https://vitejs.dev/config/).
23+
24+
## Project Setup
25+
26+
```sh
27+
pnpm install
28+
```
29+
30+
### Compile and Hot-Reload for Development
31+
32+
```sh
33+
pnpm dev
34+
```
35+
36+
### Type-Check, Compile and Minify for Production
37+
38+
```sh
39+
pnpm build
40+
```
41+
42+
### Run Unit Tests with [Vitest](https://vitest.dev/)
43+
44+
```sh
45+
pnpm test:unit
46+
```
47+
48+
### Lint with [ESLint](https://eslint.org/)
49+
50+
```sh
51+
pnpm lint
52+
```

admin/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" />

admin/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" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite App</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

admin/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "admin",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"dev": "vite",
6+
"build": "run-p type-check build-only",
7+
"preview": "vite preview --port 4173",
8+
"test:unit": "vitest --environment jsdom",
9+
"build-only": "vite build",
10+
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
11+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
12+
},
13+
"dependencies": {
14+
"pinia": "^2.0.14",
15+
"vue": "^3.2.37",
16+
"vue-router": "^4.0.16"
17+
},
18+
"devDependencies": {
19+
"@rushstack/eslint-patch": "^1.1.3",
20+
"@types/jsdom": "^16.2.14",
21+
"@types/node": "^16.11.39",
22+
"@vitejs/plugin-vue": "^2.3.3",
23+
"@vue/eslint-config-prettier": "^7.0.0",
24+
"@vue/eslint-config-typescript": "^10.0.0",
25+
"@vue/test-utils": "^2.0.0",
26+
"@vue/tsconfig": "^0.1.3",
27+
"eslint": "^8.17.0",
28+
"eslint-plugin-vue": "^8.7.1",
29+
"jsdom": "^19.0.0",
30+
"npm-run-all": "^4.1.5",
31+
"prettier": "^2.6.2",
32+
"typescript": "~4.7.3",
33+
"vite": "^2.9.12",
34+
"vitest": "^0.13.1",
35+
"vue-tsc": "^0.35.2"
36+
}
37+
}

admin/public/favicon.ico

4.19 KB
Binary file not shown.

admin/src/App.vue

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<script setup lang="ts">
2+
import { RouterLink, RouterView } from "vue-router";
3+
import HelloWorld from "@/components/HelloWorld.vue";
4+
</script>
5+
6+
<template>
7+
<header>
8+
<img
9+
alt="Vue logo"
10+
class="logo"
11+
src="@/assets/logo.svg"
12+
width="125"
13+
height="125"
14+
/>
15+
16+
<div class="wrapper">
17+
<HelloWorld msg="You did it!" />
18+
19+
<nav>
20+
<RouterLink to="/">Home</RouterLink>
21+
<RouterLink to="/about">About</RouterLink>
22+
</nav>
23+
</div>
24+
</header>
25+
26+
<RouterView />
27+
</template>
28+
29+
<style>
30+
@import "@/assets/base.css";
31+
32+
#app {
33+
max-width: 1280px;
34+
margin: 0 auto;
35+
padding: 2rem;
36+
37+
font-weight: normal;
38+
}
39+
40+
header {
41+
line-height: 1.5;
42+
max-height: 100vh;
43+
}
44+
45+
.logo {
46+
display: block;
47+
margin: 0 auto 2rem;
48+
}
49+
50+
a,
51+
.green {
52+
text-decoration: none;
53+
color: hsla(160, 100%, 37%, 1);
54+
transition: 0.4s;
55+
}
56+
57+
@media (hover: hover) {
58+
a:hover {
59+
background-color: hsla(160, 100%, 37%, 0.2);
60+
}
61+
}
62+
63+
nav {
64+
width: 100%;
65+
font-size: 12px;
66+
text-align: center;
67+
margin-top: 2rem;
68+
}
69+
70+
nav a.router-link-exact-active {
71+
color: var(--color-text);
72+
}
73+
74+
nav a.router-link-exact-active:hover {
75+
background-color: transparent;
76+
}
77+
78+
nav a {
79+
display: inline-block;
80+
padding: 0 1rem;
81+
border-left: 1px solid var(--color-border);
82+
}
83+
84+
nav a:first-of-type {
85+
border: 0;
86+
}
87+
88+
@media (min-width: 1024px) {
89+
body {
90+
display: flex;
91+
place-items: center;
92+
}
93+
94+
#app {
95+
display: grid;
96+
grid-template-columns: 1fr 1fr;
97+
padding: 0 2rem;
98+
}
99+
100+
header {
101+
display: flex;
102+
place-items: center;
103+
padding-right: calc(var(--section-gap) / 2);
104+
}
105+
106+
header .wrapper {
107+
display: flex;
108+
place-items: flex-start;
109+
flex-wrap: wrap;
110+
}
111+
112+
.logo {
113+
margin: 0 2rem 0 0;
114+
}
115+
116+
nav {
117+
text-align: left;
118+
margin-left: -1rem;
119+
font-size: 1rem;
120+
121+
padding: 1rem 0;
122+
margin-top: 1rem;
123+
}
124+
}
125+
</style>

0 commit comments

Comments
 (0)