Skip to content

Commit

Permalink
refactor: add vue2-ts teamplate
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jun 14, 2021
1 parent 93c2e01 commit 2286c7c
Show file tree
Hide file tree
Showing 34 changed files with 1,732 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"vetur.experimental.templateInterpolationService": true
}
3 changes: 3 additions & 0 deletions examples/vue2-ts/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
20 changes: 20 additions & 0 deletions examples/vue2-ts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'eslint:recommended',
'@vue/typescript/recommended',
'@vue/prettier',
],
parserOptions: {
ecmaVersion: 2020,
parser: '@typescript-eslint/parser',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
}
25 changes: 25 additions & 0 deletions examples/vue2-ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

pnpm-lock.yaml
1 change: 1 addition & 0 deletions examples/vue2-ts/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
21 changes: 21 additions & 0 deletions examples/vue2-ts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Martinus Suherman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions examples/vue2-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Vue2 + Typescript + Vite Starter Template

[![CodeFactor](https://www.codefactor.io/repository/github/martinussuherman/vue-template/badge)](https://www.codefactor.io/repository/github/martinussuherman/vue-template) [![CodeQL](https://github.com/martinussuherman/vue-template/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/martinussuherman/vue-template/actions/workflows/codeql-analysis.yml) [![Publish to Github Pages](https://github.com/martinussuherman/vue-template/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/martinussuherman/vue-template/actions/workflows/gh-pages.yml)
---

Starter template example for Vue2 + Typescript + Vite.

Note: Using pnpm for package manager.

## Project setup
```
pnpm install
```

### Compiles and hot-reloads for development
```
pnpm run serve
```

### Compiles and minifies for production
```
pnpm run build
```

### Lints and fixes files
```
pnpm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
17 changes: 17 additions & 0 deletions examples/vue2-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="/favicon.ico">
<title>Vue2 + Vite</title>
</head>
<body>
<noscript>
<strong>We're sorry but this application doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions examples/vue2-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "vue-template",
"version": "1.2.0",
"private": true,
"scripts": {
"dev": "tsc --noEmit && vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"vue": "^2.6.12",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"@types/node": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.16.1",
"@vue/eslint-config-prettier": "6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.21.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.6.0",
"prettier": "2.3.0",
"sass": "^1.32.7",
"typescript": "~4.3.2",
"vite": "^2.0.2",
"vite-plugin-components": "^0.10.2",
"vite-plugin-vue2": "^1.2.1",
"vue-template-compiler": "^2.6.12"
}
}
File renamed without changes.
32 changes: 32 additions & 0 deletions examples/vue2-ts/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view />
</div>
</template>

<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>
File renamed without changes
123 changes: 123 additions & 0 deletions examples/vue2-ts/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br />
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>
.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"
>
babel
</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router"
target="_blank"
rel="noopener"
>
router
</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex"
target="_blank"
rel="noopener"
>
vuex
</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
target="_blank"
rel="noopener"
>
eslint
</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript"
target="_blank"
rel="noopener"
>
typescript
</a>
</li>
</ul>
<h3>Essential Links</h3>
<ul>
<li>
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
</li>
<li>
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"> Forum </a>
</li>
<li>
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"> Community Chat </a>
</li>
<li>
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"> Twitter </a>
</li>
<li>
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
</li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li>
<a href="https://router.vuejs.org" target="_blank" rel="noopener"> vue-router </a>
</li>
<li>
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
</li>
<li>
<a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">
vue-devtools
</a>
</li>
<li>
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"> vue-loader </a>
</li>
<li>
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">
awesome-vue
</a>
</li>
</ul>
</div>
</template>

<script lang="ts">
export default {
props: { msg: String },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
12 changes: 12 additions & 0 deletions examples/vue2-ts/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from '@/store'

Vue.config.productionTip = false

new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app')
29 changes: 29 additions & 0 deletions examples/vue2-ts/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Home from '@/views/Home.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
},
]

const router = new VueRouter({
mode: 'history',
base: import.meta.env.BASE_URL,
routes,
})

export default router
13 changes: 13 additions & 0 deletions examples/vue2-ts/src/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue, { VNode } from 'vue'

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}
4 changes: 4 additions & 0 deletions examples/vue2-ts/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
11 changes: 11 additions & 0 deletions examples/vue2-ts/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
state: {},
mutations: {},
actions: {},
modules: {},
})
Loading

0 comments on commit 2286c7c

Please sign in to comment.