Skip to content

Commit 6ee936b

Browse files
committed
fixed 解耦
1 parent 6a0191f commit 6ee936b

File tree

4 files changed

+26
-62
lines changed

4 files changed

+26
-62
lines changed

README.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +0,0 @@
1-
# vue-ts-scaffold
2-
3-
>
4-
5-
## 此脚手架工程以 https://github.com/ws456999/vue-typescript-starter 为基础库改进实现的
6-
7-
## 特性
8-
9-
* 一键式开关(使用 config.ts 控制是否使用 typescript)
10-
* 部分 loader 使用多线程加速
11-
* 基于 webpack 3.\*及 vue-cli 最新版本(2.9.3 生成的脚手架,进行相关性改进及性能优化。
12-
13-
## 开始
14-
15-
```bash
16-
# clone this repo
17-
git clone https://github.com/xiaofan9/vue-ts-scaffold
18-
19-
# Install project dependencies
20-
npm install
21-
22-
# serve with hot reload at localhost:8080
23-
npm run dev
24-
25-
# build for production with minification
26-
npm run build
27-
```

build/vue-loader.conf.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ module.exports = {
1515
: config.dev.cssSourceMap,
1616
extract: isProduction
1717
}),
18-
config.ts
19-
? {
20-
ts: "ts-loader",
21-
tsx: "babel-loader?cacheDirectory=true!ts-loader"
22-
}
23-
: {}
18+
{
19+
ts: "ts-loader",
20+
tsx: "babel-loader?cacheDirectory=true!ts-loader"
21+
}
2422
),
2523
cssSourceMap: sourceMapEnabled,
2624
// 在模版编译过程中,编译器可以将某些属性,如 src 路径,转换为 require 调用,以便目标资源可以由 webpack 处理

build/webpack.base.conf.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,9 @@ const eslint = () => [
2828
}
2929
];
3030

31-
// typescript 解析规则
32-
const ts = () => [
33-
{
34-
test: /\.tsx$/,
35-
enforce: "pre",
36-
loader: "tslint-loader",
37-
options: {
38-
failOnHint: true
39-
// tsConfigFile: "../tslint.json"
40-
}
41-
},
42-
{
43-
test: /\.tsx?$/,
44-
include: [resolve("src")],
45-
use: [
46-
"babel-loader",
47-
{
48-
loader: "ts-loader",
49-
options: { appendTsxSuffixTo: [/\.vue$/] }
50-
}
51-
]
52-
}
53-
];
54-
5531
module.exports = {
5632
entry: {
57-
// 根据配置文件判断是否载入 ts
58-
app: config.ts ? "./src/main.ts" : "./src/main.js"
33+
app: "./src/main.ts"
5934
},
6035
output: {
6136
path: config.build.assetsRoot,
@@ -79,7 +54,26 @@ module.exports = {
7954
rules: [
8055
// 根据 vue-cli 来,根据参数判断是否载入eslint配置
8156
...(config.dev.useEslint ? eslint() : []),
82-
...(config.ts ? ts() : []),
57+
{
58+
test: /\.tsx$/,
59+
enforce: "pre",
60+
loader: "tslint-loader",
61+
options: {
62+
failOnHint: true
63+
// tsConfigFile: "../tslint.json"
64+
}
65+
},
66+
{
67+
test: /\.tsx?$/,
68+
include: [resolve("src")],
69+
use: [
70+
"babel-loader",
71+
{
72+
loader: "ts-loader",
73+
options: { appendTsxSuffixTo: [/\.vue$/] }
74+
}
75+
]
76+
},
8377
{
8478
test: /\.js$/,
8579
loader: "babel-loader?cacheDirectory=true",

config/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ module.exports = {
5151
cssSourceMap: true,
5252
// 外部依赖库配置 key 库名称 value window全局变量名称
5353
externals: {}
54-
},
55-
ts: true
54+
}
5655
};

0 commit comments

Comments
 (0)