Skip to content

Commit 0f91c2d

Browse files
committed
first commit
0 parents  commit 0f91c2d

38 files changed

+869
-0
lines changed

.eslintrc.cjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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',
10+
'@vue/eslint-config-prettier'
11+
],
12+
overrides: [
13+
{
14+
files: [
15+
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'
16+
],
17+
'extends': [
18+
'plugin:cypress/recommended'
19+
]
20+
}
21+
],
22+
parserOptions: {
23+
ecmaVersion: 'latest'
24+
}
25+
}

.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?

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.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+
}

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# frontend-vuejs-boilerplate
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+
npm install
28+
```
29+
30+
### Compile and Hot-Reload for Development
31+
32+
```sh
33+
npm run dev
34+
```
35+
36+
### Type-Check, Compile and Minify for Production
37+
38+
```sh
39+
npm run build
40+
```
41+
42+
### Run Unit Tests with [Vitest](https://vitest.dev/)
43+
44+
```sh
45+
npm run test:unit
46+
```
47+
48+
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
49+
50+
```sh
51+
npm run test:e2e:dev
52+
```
53+
54+
This runs the end-to-end tests against the Vite development server.
55+
It is much faster than the production build.
56+
57+
But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
58+
59+
```sh
60+
npm run build
61+
npm run test:e2e
62+
```
63+
64+
### Lint with [ESLint](https://eslint.org/)
65+
66+
```sh
67+
npm run lint
68+
```

cypress.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
e2e: {
5+
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
6+
baseUrl: 'http://localhost:4173'
7+
}
8+
})

cypress/e2e/example.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://docs.cypress.io/api/introduction/api.html
2+
3+
describe('My First Test', () => {
4+
it('visits the app root url', () => {
5+
cy.visit('/')
6+
cy.contains('h1', 'You did it!')
7+
})
8+
})

cypress/e2e/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "@vue/tsconfig/tsconfig.web.json",
3+
"include": ["./**/*", "../support/**/*"],
4+
"compilerOptions": {
5+
"isolatedModules": false,
6+
"target": "es5",
7+
"lib": ["es5", "dom"],
8+
"types": ["cypress"]
9+
}
10+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/support/commands.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************
3+
// This example commands.ts shows you how to
4+
// create various custom commands and overwrite
5+
// existing commands.
6+
//
7+
// For more comprehensive examples of custom
8+
// commands please read more here:
9+
// https://on.cypress.io/custom-commands
10+
// ***********************************************
11+
//
12+
//
13+
// -- This is a parent command --
14+
// Cypress.Commands.add('login', (email, password) => { ... })
15+
//
16+
//
17+
// -- This is a child command --
18+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19+
//
20+
//
21+
// -- This is a dual command --
22+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23+
//
24+
//
25+
// -- This will overwrite an existing command --
26+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }
38+
39+
export {}

cypress/support/e2e.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

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

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>

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "frontend-vuejs-boilerplate",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "run-p type-check build-only",
8+
"preview": "vite preview",
9+
"test:unit": "vitest --environment jsdom --root src/",
10+
"test:e2e": "start-server-and-test preview :4173 'cypress run --e2e'",
11+
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' :4173 'cypress open --e2e'",
12+
"build-only": "vite build",
13+
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
14+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
15+
},
16+
"dependencies": {
17+
"pinia": "^2.0.26",
18+
"vue": "^3.2.45",
19+
"vue-router": "^4.1.6"
20+
},
21+
"devDependencies": {
22+
"@rushstack/eslint-patch": "^1.1.4",
23+
"@types/jsdom": "^20.0.1",
24+
"@types/node": "^18.11.9",
25+
"@vitejs/plugin-vue": "^3.2.0",
26+
"@vitejs/plugin-vue-jsx": "^2.1.1",
27+
"@vue/eslint-config-prettier": "^7.0.0",
28+
"@vue/eslint-config-typescript": "^11.0.0",
29+
"@vue/test-utils": "^2.2.4",
30+
"@vue/tsconfig": "^0.1.3",
31+
"cypress": "^11.2.0",
32+
"eslint": "^8.22.0",
33+
"eslint-plugin-cypress": "^2.12.1",
34+
"eslint-plugin-vue": "^9.3.0",
35+
"jsdom": "^20.0.3",
36+
"npm-run-all": "^4.1.5",
37+
"prettier": "^2.7.1",
38+
"start-server-and-test": "^1.14.0",
39+
"typescript": "~4.7.4",
40+
"vite": "^3.2.4",
41+
"vitest": "^0.25.3",
42+
"vue-tsc": "^1.0.9"
43+
}
44+
}

public/favicon.ico

4.19 KB
Binary file not shown.

src/App.vue

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
9+
10+
<div class="wrapper">
11+
<HelloWorld msg="You did it!" />
12+
13+
<nav>
14+
<RouterLink to="/">Home</RouterLink>
15+
<RouterLink to="/about">About</RouterLink>
16+
</nav>
17+
</div>
18+
</header>
19+
20+
<RouterView />
21+
</template>
22+
23+
<style scoped>
24+
header {
25+
line-height: 1.5;
26+
max-height: 100vh;
27+
}
28+
29+
.logo {
30+
display: block;
31+
margin: 0 auto 2rem;
32+
}
33+
34+
nav {
35+
width: 100%;
36+
font-size: 12px;
37+
text-align: center;
38+
margin-top: 2rem;
39+
}
40+
41+
nav a.router-link-exact-active {
42+
color: var(--color-text);
43+
}
44+
45+
nav a.router-link-exact-active:hover {
46+
background-color: transparent;
47+
}
48+
49+
nav a {
50+
display: inline-block;
51+
padding: 0 1rem;
52+
border-left: 1px solid var(--color-border);
53+
}
54+
55+
nav a:first-of-type {
56+
border: 0;
57+
}
58+
59+
@media (min-width: 1024px) {
60+
header {
61+
display: flex;
62+
place-items: center;
63+
padding-right: calc(var(--section-gap) / 2);
64+
}
65+
66+
.logo {
67+
margin: 0 2rem 0 0;
68+
}
69+
70+
header .wrapper {
71+
display: flex;
72+
place-items: flex-start;
73+
flex-wrap: wrap;
74+
}
75+
76+
nav {
77+
text-align: left;
78+
margin-left: -1rem;
79+
font-size: 1rem;
80+
81+
padding: 1rem 0;
82+
margin-top: 1rem;
83+
}
84+
}
85+
</style>

0 commit comments

Comments
 (0)