-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.base.config.js
98 lines (94 loc) · 2.91 KB
/
webpack.base.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
88
89
90
91
92
93
94
95
96
97
98
// External
const path = require("path");
const moment = require("moment");
const GitRevisionPlugin = require("git-revision-webpack-plugin");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const rawBuildDate = new Date();
// Build datestring
// Regex for extracting the timezone from http://stackoverflow.com/a/15304657
const buildDate = `${moment(rawBuildDate).format("YYYY-MM-DD HH:mm")} ${rawBuildDate.toString().match(/([A-Z]+[\+-][0-9]+)/)[1]}`;
module.exports = {
context: path.resolve(__dirname, "src"),
plugins: [
(gitRevisionPlugin = new GitRevisionPlugin({
lightweightTags: true
})),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src", "index.html"),
inject: "head"
})
],
resolve: {
extensions: [".js", ".ts", ".json", "vue"],
alias: {
vue$: "vue/dist/vue.esm.js"
}
},
module: {
rules: [
{
test: /(\.ts|\.js)$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/]
}
},
{
test: /\.vue$/,
loader: "vue-loader",
options: {
loaders: {
ts: "ts-loader!tslint-loader"
},
esModule: true
}
},
{
test: /\.html$/,
loader: "html-loader",
options: {
name: "[name].[ext]"
},
exclude: /node_modules/
},
{
test: /\.less$/,
use: ["vue-style-loader", "css-loader", "less-loader"],
exclude: /node_modules/
},
{
test: /\.css$/,
use: ["vue-style-loader", "css-loader"]
},
{
test: /(\.png|\.ico|\.jpg|\.svg)$/,
loader: "file-loader",
options: {
name: "imgs/**/[name].[ext]"
}
},
// String replacement
{
test: /\.ts$/,
include: [path.resolve(__dirname, "src/config")],
enforce: "pre",
loader: "string-replace-loader",
query: {
multiple: [
{
search: "$VERSION",
replace: gitRevisionPlugin.version()
},
{
search: "$BUILDDATE",
replace: buildDate
}
]
}
}
]
}
};