|
1 | 1 | # Base Vue Project |
2 | 2 |
|
3 | | -A Vue 3 + TypeScript starter using Vue CLI (serve/build), Vite (Cypress Component Testing), Yarn 4, ESLint (Airbnb + Vue), and Sass. |
| 3 | +A Vue 3 + TypeScript starter using Vite, Vitest, Yarn 4, ESLint, and Sass. |
4 | 4 |
|
5 | 5 | ## Requirements |
| 6 | + |
6 | 7 | - Node 22+ |
7 | | -- Yarn 4 (via Corepack) |
| 8 | +- Yarn 4 via Corepack |
8 | 9 |
|
9 | 10 | ```bash |
10 | 11 | corepack enable |
11 | | -node -v # should be 22.x |
12 | | -yarn -v # Yarn 4.x |
| 12 | +node -v |
| 13 | +yarn -v |
13 | 14 | ``` |
14 | 15 |
|
15 | 16 | ## Quickstart |
| 17 | + |
16 | 18 | ```bash |
17 | 19 | yarn install --immutable |
18 | | -yarn serve |
| 20 | +yarn dev |
19 | 21 | ``` |
20 | | -- Dev server: http://localhost:8080 |
| 22 | + |
| 23 | +The dev server runs at the URL printed by Vite, usually http://localhost:5173. |
21 | 24 |
|
22 | 25 | ## Scripts |
23 | | -- `yarn serve`: start the Vue CLI dev server |
24 | | -- `yarn build`: production build to `dist/` |
| 26 | + |
| 27 | +- `yarn dev`: start the Vite dev server |
| 28 | +- `yarn serve`: alias for `yarn dev` |
| 29 | +- `yarn build`: type-check and create a production build in `dist/` |
| 30 | +- `yarn preview`: preview the production build locally |
25 | 31 | - `yarn lint`: run ESLint checks |
26 | | -- `yarn test`: lint then open Cypress Component Test Runner (defaults to Firefox) |
27 | | -- `yarn test:chrome`: lint then open Cypress in Chrome |
28 | | -- `yarn test:headless`: lint then run headless component tests (used in CI) |
29 | | - |
30 | | -## Testing (Cypress Component) |
31 | | -- Bundler: Vite; Framework: Vue (`cypress.config.ts`) |
32 | | -- Spec pattern: `src/**/*.spec.{ts,tsx,js,jsx}` |
33 | | -- Example: `src/tests/Foo.spec.ts` |
34 | | -- Open runner: |
35 | | - ```bash |
36 | | - yarn test # Firefox |
37 | | - yarn test:chrome # Chrome |
38 | | - ``` |
39 | | -- Headless (CI-equivalent): |
40 | | - ```bash |
41 | | - yarn test:headless |
42 | | - ``` |
43 | | - |
44 | | -## Linting |
45 | | -- Config: Flat ESLint with `plugin:vue/recommended` + `airbnb-base` and TypeScript rules. |
46 | | -- Run: |
47 | | - ```bash |
48 | | - yarn lint |
49 | | - # optional: |
50 | | - yarn eslint . --fix |
51 | | - ``` |
52 | | -- Tip: Install the “ESLint” editor extension for inline feedback. |
| 32 | +- `yarn typecheck`: run Vue-aware TypeScript checks |
| 33 | +- `yarn test`: run Vitest once |
| 34 | +- `yarn test:watch`: run Vitest in watch mode |
| 35 | + |
| 36 | +## Testing |
| 37 | + |
| 38 | +Vitest runs component tests in a jsdom environment. Component tests use Vue Test Utils. |
| 39 | + |
| 40 | +```bash |
| 41 | +yarn test |
| 42 | +``` |
| 43 | + |
| 44 | +The example component test lives at `src/tests/Foo.spec.ts`. |
| 45 | + |
| 46 | +## Linting And Type Checking |
| 47 | + |
| 48 | +The project uses ESLint flat config with Vue and TypeScript parsing. |
| 49 | + |
| 50 | +```bash |
| 51 | +yarn lint |
| 52 | +yarn typecheck |
| 53 | +``` |
53 | 54 |
|
54 | 55 | ## CI |
55 | | -- GitHub Actions run on pushes/PRs to `main`, using Node 22 + Yarn 4 via Corepack and `yarn test:headless`. |
56 | | -- Workflow file: `.github/workflows/node.js.yml` |
57 | 56 |
|
58 | | -## Tech stack |
| 57 | +GitHub Actions run on pushes and pull requests to `main` using Node 22 and Yarn 4: |
| 58 | + |
| 59 | +```bash |
| 60 | +yarn install --immutable |
| 61 | +yarn lint |
| 62 | +yarn typecheck |
| 63 | +yarn test |
| 64 | +yarn build |
| 65 | +``` |
| 66 | + |
| 67 | +Workflow file: `.github/workflows/node.js.yml`. |
| 68 | + |
| 69 | +## Tech Stack |
| 70 | + |
59 | 71 | - Vue 3, TypeScript |
60 | | -- Vue Router, Vuex |
61 | | -- Build/serve: Vue CLI |
62 | | -- Component tests: Cypress (+ Vite bundler) |
63 | | -- Styling: Sass |
| 72 | +- Vite |
| 73 | +- Vitest, Vue Test Utils, jsdom |
| 74 | +- Vue Router and Vuex are installed as starter dependencies |
| 75 | +- Sass |
64 | 76 |
|
65 | | -## Project structure |
| 77 | +## Project Structure |
66 | 78 |
|
67 | | -``` |
| 79 | +```text |
68 | 80 | base-vue/ |
69 | | -├── babel.config.js # Babel configuration |
70 | | -├── vue.config.js # Vue CLI configuration |
71 | | -├── vite.config.ts # Vite configuration for Cypress |
72 | | -├── cypress.config.ts # Cypress configuration |
73 | | -├── eslint.config.cjs # ESLint configuration |
| 81 | +├── index.html |
| 82 | +├── vite.config.ts |
| 83 | +├── eslint.config.cjs |
| 84 | +├── tsconfig.json |
74 | 85 | ├── public/ |
75 | | -│ ├── index.html # HTML template |
76 | | -│ └── favicon.ico # Site favicon |
| 86 | +│ └── favicon.ico |
77 | 87 | ├── src/ |
78 | | -│ ├── main.ts # Vue app entry point |
79 | | -│ ├── App.vue # Root Vue component |
80 | | -│ ├── App.scss # Global styles |
| 88 | +│ ├── main.ts |
| 89 | +│ ├── App.vue |
| 90 | +│ ├── App.scss |
| 91 | +│ ├── vite-env.d.ts |
81 | 92 | │ ├── assets/ |
82 | | -│ │ └── logo.png # Static assets |
| 93 | +│ │ └── logo.png |
83 | 94 | │ ├── components/ |
84 | | -│ │ ├── Foo.vue # Example component |
85 | | -│ │ └── Foo.scss # Component styles |
| 95 | +│ │ ├── Foo.vue |
| 96 | +│ │ └── Foo.scss |
86 | 97 | │ └── tests/ |
87 | | -│ └── Foo.spec.ts # Component tests |
88 | | -├── cypress/ |
89 | | -│ ├── fixtures/ # Test data |
90 | | -│ ├── plugins/ # Cypress plugins |
91 | | -│ ├── support/ # Support files |
92 | | -│ ├── downloads/ # Downloaded files during tests |
93 | | -│ └── screenshots/ # Test screenshots |
94 | | -├── .github/ |
95 | | -│ └── workflows/ |
96 | | -│ └── node.js.yml # CI/CD workflow |
97 | | -``` |
| 98 | +│ └── Foo.spec.ts |
| 99 | +└── .github/ |
| 100 | + └── workflows/ |
| 101 | + └── node.js.yml |
| 102 | +``` |
0 commit comments