-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
87 lines (73 loc) · 1.75 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const {
resolve
} = require("path");
let build_mode = process.env.BUILD_MODE;
build_mode = build_mode ? build_mode.trim() : build_mode;
const isDev = ["", "undefined", undefined, "null", null].includes(build_mode);
console.log(`isDev -> ${isDev}`);
if (!isDev) {
console.log(`build_mode -> ${build_mode}`);
}
const config = {
lintOnSave: false,
parallel: false,
productionSourceMap: false,
};
if (isDev) {
// dev
Object.assign(config, {
pages: {
index: {
entry: "src/demos/main.ts",
template: "public/index.html",
filename: "index.html",
}
},
devServer: {
port: 1234,
},
});
}
if (build_mode === "production") {
// production
}
if (build_mode === "lib") {
// lib
Object.assign(config, {
configureWebpack: (config) => {
config.externals = {
vue: 'vue',
};
},
chainWebpack: config => {
config
.entry("app")
.clear()
.add("./src/packages/index.ts");
// config.module
// .rule("js")
// .exclude.add(resolve("src/lib/jsdifflib/jsdifflib.js"))
// .add(resolve("src/lib/qunee/Q.js"));
config.module
.rule("ts")
.use("ts-loader")
.loader("ts-loader")
.tap(options => {
options.transpileOnly = false;
return options;
});
config.module
.rule("tsx")
.use("ts-loader")
.loader("ts-loader")
.tap(options => {
options.transpileOnly = false;
return options;
});
/* 移除 cache-loader,使之生成类型定义文件 */
config.module.rule("ts").uses.delete("cache-loader");
config.module.rule("tsx").uses.delete("cache-loader");
},
});
}
module.exports = config;