Skip to content

Commit

Permalink
feat: add vue-tsc example
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Mar 30, 2021
1 parent be8ea9b commit 17d5d3b
Show file tree
Hide file tree
Showing 13 changed files with 587 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ See [./examples](./examples) to have a try.
```bash
pnpm i
cd ./examples/<ONE_EXAMPLE>
vite
npm run dev
```

### Roadmap

- [x] release alpha version
- [ ] support build mode
- [ ] custom command
- [ ] custom tsconfig
- [ ] no tsconfig hint
- [ ] custom tsconfig path
- [ ] no tsconfig file error
- [ ] examples (codesandbox?)
- [ ] release stable version

Expand Down
Empty file removed examples/vue-ts/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions examples/vue-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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>
20 changes: 20 additions & 0 deletions examples/vue-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "vite-vue-typescript-starter",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview"
},
"dependencies": {
"vue": "^3.0.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.1.5",
"@vue/compiler-sfc": "^3.0.5",
"typescript": "^4.1.3",
"vite": "^2.1.3",
"vite-plugin-ts-checker": "workspace:*",
"vue-tsc": "^0.0.15"
}
}
Binary file added examples/vue-ts/public/favicon.ico
Binary file not shown.
27 changes: 27 additions & 0 deletions examples/vue-ts/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld />
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import HelloWorld from './components/HelloWorld.vue'
export default defineComponent({
name: 'App',
components: {
HelloWorld,
},
})
</script>

<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>
Binary file added examples/vue-ts/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions examples/vue-ts/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<h1>{{ msg }}</h1>

<p>
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
+
<a
href="https://marketplace.visualstudio.com/items?itemName=octref.vetur"
target="_blank"
>Vetur</a>
or
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
(if using
<code>&lt;script setup&gt;</code>)
</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 @click="count++">count is: {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>

<script lang="ts">
import { ref, defineComponent } from 'vue'
export default defineComponent({
name: 'HelloWorld',
props: {
msg: {
type: String,
required: true
}
},
setup: () => {
const count = ref(0)
return { count }
}
})
</script>

<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>
4 changes: 4 additions & 0 deletions examples/vue-ts/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')
5 changes: 5 additions & 0 deletions examples/vue-ts/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
15 changes: 15 additions & 0 deletions examples/vue-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vite/client"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
8 changes: 8 additions & 0 deletions examples/vue-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import TsChecker from 'vite-plugin-ts-checker'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), TsChecker()],
})
Loading

0 comments on commit 17d5d3b

Please sign in to comment.