Skip to content

Commit 19613f3

Browse files
committed
INIT
1 parent f9a5d98 commit 19613f3

25 files changed

+573
-2
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": ["@babel/env", "@babel/typescript", "@vue/babel-preset-jsx"],
3+
"plugins": [
4+
"@babel/proposal-numeric-separator",
5+
[
6+
"@babel/proposal-decorators",
7+
{
8+
"legacy": true
9+
}
10+
],
11+
["@babel/proposal-class-properties", { "loose": false }],
12+
"@babel/proposal-object-rest-spread"
13+
]
14+
}

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[*.{js,jsx,ts,tsx,vue}]
2+
indent_style = space
3+
indent_size = 2
4+
trim_trailing_whitespace = true
5+
insert_final_newline = true

.eslintrc.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module.exports = {
2+
plugins: ["vue", "@typescript-eslint"],
3+
parserOptions: {
4+
parser: "@typescript-eslint/parser",
5+
env: { es6: true },
6+
sourceType: "module",
7+
ecmaFeatures: {
8+
legacyDecorators: true,
9+
experimentalObjectRestSpread: true
10+
}
11+
},
12+
root: true,
13+
env: {
14+
browser: true,
15+
node: true
16+
},
17+
extends: [
18+
"plugin:vue/base",
19+
"plugin:@typescript-eslint/recommended",
20+
"plugin:vue/essential",
21+
"standard"
22+
],
23+
rules: {
24+
// default eslint rules
25+
"one-var": 0,
26+
"arrow-parens": 0,
27+
"generator-star-spacing": 0,
28+
"no-debugger": 0,
29+
"no-console": 0,
30+
semi: [2, "always"],
31+
"no-extra-semi": 2,
32+
"space-before-function-paren": 0,
33+
eqeqeq: 0,
34+
"spaced-comment": 0,
35+
"no-useless-escape": 0,
36+
"no-tabs": 0,
37+
"no-mixed-spaces-and-tabs": 0,
38+
"new-cap": 0,
39+
camelcase: 0,
40+
"no-new": 0,
41+
indent: "off",
42+
semi: "off",
43+
"no-unused-vars": "off",
44+
"@typescript-eslint/no-unused-vars": [
45+
"error",
46+
{
47+
argsIgnorePattern: "^h$"
48+
}
49+
],
50+
// typescript-eslint rules
51+
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules
52+
"@typescript-eslint/semi": ["error"],
53+
"@typescript-eslint/indent": ["error", 2],
54+
"@typescript-eslint/explicit-function-return-type": 0,
55+
"@typescript-eslint/no-inferrable-types": 0
56+
}
57+
};

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
/test/unit/coverage/
7+
/test/e2e/reports/
8+
selenium-debug.log
9+
10+
package-lock.json
11+
12+
# Editor directories and files
13+
.idea
14+
.vscode
15+
*.suo
16+
*.ntvs*
17+
*.njsproj
18+
*.sln
19+

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
trailingComma: 'none',
3+
printWidth: 130,
4+
bracketSpacing: true,
5+
arrowParens: 'always',
6+
tabWidth: 2,
7+
semi: true,
8+
singleQuote: true,
9+
jsxBracketSameLine: true
10+
};

@types/shims-tsx.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue, { VNode } from 'vue'
2+
3+
declare global {
4+
namespace JSX {
5+
// tslint:disable no-empty-interface
6+
interface Element extends VNode {}
7+
// tslint:disable no-empty-interface
8+
interface ElementClass extends Vue {}
9+
interface IntrinsicElements {
10+
[elem: string]: any
11+
}
12+
}
13+
}

@types/shims-vue.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.vue' {
2+
import Vue from 'vue'
3+
export default Vue
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 leevy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# typeScript-vue-starter
2-
typeScript+vue示例
1+
## TypeScript-vue-Starter
2+
3+
## Start
4+
5+
```shell
6+
npm install
7+
npm run dev
8+
npm run build
9+
```
10+
11+
## keywords
12+
```
13+
Webpack 4.0+
14+
Typescript 3.7+
15+
Eslint 6.0+
16+
Vue 2.0+
17+
Babel 7.0+
18+
19+
```
20+
21+
## 项目结构
22+
23+
```
24+
├── /@types/ # 全局类型声明
25+
├── /build/ # webpack配置文件
26+
├── /src/ # 源码目录
27+
│ ├── /assets/ # 静态资源目录
28+
│ ├── /components/ # 公共组件目录
29+
│ ├── /constants/ # 项目constants目录
30+
│ │ ├── _const.less # less常量
31+
│ ├── /pages/ # UI组件目录
32+
│ ├── /services/ # 请求服务目录
33+
│ ├── /router/ # 路由目录
34+
│ ├── /store/ # 存放store文件目录
35+
│ ├── /style/ # 全局样式
36+
│ ├── /utils/ # utils目录
37+
│ │ ├── request.ts # 基于fetch封装的API请求工具
38+
│ │ ├── global.ts # 公共方法库
39+
│ └── index.tsx # 项目入口
40+
|——tsconfig.json # ts配置
41+
|——...
42+
```

build/webpack.config.js

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/* eslint @typescript-eslint/no-var-requires:off */
2+
const path = require('path'),
3+
Html = require('html-webpack-plugin'),
4+
ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'),
5+
VueLoaderPlugin = require('vue-loader/lib/plugin.js');
6+
function resolve(dir) {
7+
return path.join(__dirname, '..', dir);
8+
}
9+
module.exports = {
10+
entry: './src/main.ts',
11+
output: {
12+
path: path.resolve(__dirname, './'),
13+
publicPath: './',
14+
filename: 'chunk.[hash].js'
15+
},
16+
module: {
17+
rules: [
18+
{
19+
test: /\.vue$/,
20+
loader: 'vue-loader',
21+
options: {
22+
compilerOptions: {
23+
preserveWhitespace: false
24+
}
25+
}
26+
},
27+
{
28+
test: /\.(js|jsx)$/,
29+
loader: 'babel-loader'
30+
},
31+
{
32+
test: /\.ts(x)?$/,
33+
exclude: /node_modules/,
34+
use: [
35+
'babel-loader',
36+
{
37+
loader: 'ts-loader',
38+
options: {
39+
appendTsSuffixTo: [/\.vue$/]
40+
}
41+
}
42+
]
43+
},
44+
{
45+
test: /\.(png|jpg|gif|svg)$/,
46+
loader: 'file-loader',
47+
options: {
48+
name: '[name].[ext]?[hash]'
49+
}
50+
},
51+
{
52+
test: /\.(sa|sc|c)ss$/,
53+
resourceQuery: /\?vue/,
54+
use: [
55+
{
56+
loader: 'vue-style-loader',
57+
options: {
58+
sourceMap: false,
59+
shadowMode: false
60+
}
61+
},
62+
{
63+
loader: 'css-loader'
64+
},
65+
{
66+
loader: 'sass-loader'
67+
}
68+
]
69+
},
70+
{
71+
test: /\.(js|vue|ts|tsx|jsx)$/,
72+
enforce: 'pre',
73+
exclude: /node_modules/,
74+
use: [
75+
{
76+
loader: 'eslint-loader',
77+
options: {
78+
fix: false,
79+
extensions: ['.js', '.jsx', '.vue', '.ts', '.tsx'],
80+
cache: false,
81+
emitWarning: true,
82+
emitError: true
83+
}
84+
}
85+
]
86+
}
87+
]
88+
},
89+
node: false,
90+
plugins: [
91+
new VueLoaderPlugin(),
92+
new Html({
93+
template: resolve('src/index.html'),
94+
filename: 'index.html'
95+
}),
96+
new ForkTsCheckerWebpackPlugin({
97+
vue: true,
98+
tslint: false,
99+
checkSyntacticErrors: true
100+
})
101+
],
102+
resolve: {
103+
extensions: ['.ts', '.js', '.vue', '.json', '.jsx', '.tsx'],
104+
alias: {
105+
vue$: 'vue/dist/vue.esm.js',
106+
'@': resolve('src')
107+
}
108+
},
109+
devServer: {
110+
historyApiFallback: true,
111+
noInfo: true,
112+
port: 8080,
113+
contentBase: [path.join(__dirname, '../')],
114+
hot: true,
115+
host: '0.0.0.0',
116+
compress: true,
117+
quiet: false,
118+
disableHostCheck: true,
119+
publicPath: '/',
120+
overlay: {
121+
warnings: true
122+
}
123+
},
124+
performance: {
125+
hints: false
126+
},
127+
devtool: '#eval-source-map'
128+
};

0 commit comments

Comments
 (0)