-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwebpack.base.config.js
108 lines (105 loc) · 2.55 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
99
100
101
102
103
104
105
106
107
108
var path = require("path");
//导出插件
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
output: {
path: path.join(__dirname, "./dist"), //指定输出目录
libraryTarget: "umd",
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: "css-loader",
fallback: "style-loader"
})
},
{
test: /\.vue$/,
use: [
{
loader: "vue-loader",
options: {
loaders: {
css: ExtractTextPlugin.extract({
use: "css-loader",
fallback: "vue-style-loader"
}),
less:ExtractTextPlugin.extract({
use: "less-loader",
fallback: "vue-style-loader"
})
}
}
}
]
},
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/
//include: [path.resolve(__dirname, "src"), path.resolve(__dirname, "node_modules/iview/src")]
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "less-loader",
options: {
sourceMap: true
}
}
]
},
{
//此处配置为iview的注意点,如果不配置的话 无法再Js文件中加载iview.css文件;其次如果使用url-loader无法加载的话,会使用file-loader进行文件加载
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: "url-loader?limit=1024",
options: {
limit: 10000,
name: "img/[name].[hash].[ext]"
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: "url-loader",
options: {
limit: 10000,
name: "media/[name].[hash].[ext]"
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: "url-loader",
options: {
limit: 10000,
name: "fonts/[name].[hash].[ext]"
}
},
{
test: /\.(html|tpl)$/,
loader: "html-loader"
}
]
},
plugins: [],
resolve: {
extensions: [".js", ".vue", ".json"],
//设置别名
alias: {
vue: "vue/dist/vue.esm.js",
"@": path.resolve("src")
}
}
};