-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.js
62 lines (60 loc) · 1.94 KB
/
webpack.base.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
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const friendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const setMPA = require('./utils/setMPA');
const { entry, htmlWebpackPlugins } = setMPA();
module.exports = {
entry,
module: {
rules: [
{
test: /\.js|jsx$/,
use: [
{
loader: 'thread-loader',
options: {
workers: 3
} // 必须在最前面
},
'babel-loader'
]
},
{
test: /\.css$/,
use: [
// 'style-loader',
MiniCssExtractPlugin.loader,
{ loader: 'css-loader' }
]
},
{
test: /\.less$/,
use: [
// 'style-loader',
MiniCssExtractPlugin.loader,
{ loader: 'css-loader' },
{ loader: 'less-loader' }
]
},
{
test: /\.(ico|png|jpg|jpeg|mp4|mp3|gif|mov)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192, // 限制字节(如果图片或者字体的字节数小于此数值,自动转换为base64)
name: '[name]_[hash:8].[ext]'
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(), // 打包前清空dist目录
new MiniCssExtractPlugin({
filename: '[name]_[contenthash:8].css'
}),
new friendlyErrorsWebpackPlugin()
].concat(htmlWebpackPlugins)
}