-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
61 lines (59 loc) · 1.65 KB
/
webpack.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
const path = require("path");
module.exports = {
mode: "development",
devtool: "source-map",
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
},
resolveLoader: {
alias: {
"file-loader": path.resolve(__dirname, "src", "file-loader"),
"url-loader": path.resolve(__dirname, "src", "url-loader"),
"babel-loader": path.resolve(__dirname, "src", "babel-loader"),
"banner-loader": path.resolve(__dirname, "src", "banner-loader"),
"style-loader": path.resolve(__dirname, "src", "style-loader"),
"css-loader": path.resolve(__dirname, "src", "css-loader"),
"less-loader": path.resolve(__dirname, "src", "less-loader")
}
},
module: {
rules: [
{
test: /\.less$/,
use: ["style-loader", "css-loader", "less-loader"]
},
{
test: /\.(png|jpe?g|webp|gif)$/,
use: {
// loader: "file-loader" // 根据图片生成一个md5,保存到dist目录下,同时返回当前的图片路径
// 经过file-loader处理路径,并根据limit转换成base64
loader: "url-loader",
options: {
limit: 200 * 1024
}
}
},
{
test: /\.js$/,
use: [
{
// 生成文件注释
loader: "banner-loader",
options: {
text: "qm",
filename: path.resolve(__dirname, "src", "assets", "banner.txt")
}
},
{
loader: "babel-loader",
options: {
presets: ["@babel/env"]
}
}
]
}
]
}
};