Commit 4c6bc264 authored by 曾沂轮's avatar 曾沂轮

Feat: 初始工程

parents
# svi-cli vue-app Template
> 一个基于vite搭建的vue + typescript路由应用模板,提供给svi-cli脚手架获取.
> 提供内部用Vuejs开发页面的初始模板
> 主要包含 `vue`, `@smart/eslint-config-typescript` 智能的规范
## Usage / 用法
``` bash
$ npm install -g svi-cli
$ svi init vue3-app my-project
$ cd my-project
$ npm install
$ npm run serve
```
module.exports = {
renderFiles: [
'package.json',
'README.md'
],
filters: {
},
prompts: {
name: {
type: 'string',
required: true,
message: 'Project name'
},
description: {
type: 'string',
required: false,
message: 'Project description',
default: 'A vue3 and typescript project',
},
author: {
type: 'string',
message: 'Author'
}
}
}
\ No newline at end of file
{
"name": "vue3-app",
"version": "0.0.1",
"description": "a svi CLI vue3 and typescript app template.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"template"
],
"author": "zengyl@southzn.com",
"license": "MIT"
}
*.d.ts
vite.config.ts
public/
assets/
\ No newline at end of file
module.exports = {
env: {
node: true,
},
parser: 'vue-eslint-parser',
parserOptions: {
parser: require.resolve('@typescript-eslint/parser'),
extraFileExtensions: ['.vue'],
ecmaFeatures: {
jsx: true,
},
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:vue/vue3-recommended',
'prettier',
'@vue/prettier',
'@smart/typescript',
],
rules: {
// vue
'vue/html-self-closing': [
'error',
{
html: {
void: 'any',
normal: 'never',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
'vue/max-attributes-per-line': [
'error',
{
singleline: {
max: 4,
allowFirstLine: true,
},
multiline: {
max: 1,
allowFirstLine: true,
},
},
],
'vue/require-default-prop': 'off',
},
globals: {
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
},
};
node_modules
.DS_Store
dist
dist-ssr
*.local
# Ignore everything
*
# Unignore directories (to all depths) and unignore code and style files in these directories
!src/**/
!**/*.js
!**/*.jsx
!**/*.css
!**/*.scss
!**/*.html
!**/*.vue
!**/*.md
!**/*.ts
!**/*.tsx
# some souces directories
src/assets
#
CHANGELOG.md
vue.config.js
babel.config.js
commitlint.config.js
vite.config.js
.eslintrc.js
module.exports = {
tabWidth: 2,
trailingComma: 'all',
semi: true,
singleQuote: true,
printWidth: 100,
};
{
"recommendations": ["johnsoncodehk.volar"]
}
# {{name}}
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
## Producer
South Smart EF团队。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
{
"name": "{{ name }}",
"version": "0.0.0",
"description": "{{ description }}",
"author":"{{ author }}",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"lint": "eslint \"src/*.ts\" \"src/**\" --fix"
},
"dependencies": {
"vue": "^3.2.6"
},
"devDependencies": {
"@smart/eslint-config-typescript": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@vitejs/plugin-vue": "^1.6.1",
"@vue/compiler-sfc": "^3.2.6",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^7.17.0",
"prettier": "^2.4.1",
"typescript": "^4.3.2",
"vite": "^2.5.4",
"vue-tsc": "^0.2.2"
}
}
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import HelloWorld from './components/HelloWorld.vue';
</script>
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<script setup lang="ts">
import { ref } from 'vue';
defineProps<{ msg: string }>();
const count = ref(0);
</script>
<template>
<h1>{{ msg }}</h1>
<p style="border: 1px solid">
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
+
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
</p>
<p>See <code>README.md</code> for more information.</p>
<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank"> Vite Docs </a>
|
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<button type="button" @click="count++">count is: {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>
<style scoped>
a {
color: #42b983;
}
label {
margin: 0 0.5em;
font-weight: bold;
}
code {
background-color: #eee;
padding: 2px 4px;
border-radius: 4px;
color: #304455;
}
</style>
/// <reference types="vite/client" />
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"]
},
"paths": {
"@/*": [
"src/*"
],
"@components/*": [
"src/components/*"
]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules", "dist"]
}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment