-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.base.config.js
82 lines (76 loc) · 1.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
const path = require('path');
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const BUILD_PATH = path.resolve(__dirname, 'dist');
const SRC_PATH = path.resolve('./src');
const aliasObj = {
react: path.join(__dirname, 'node_modules', 'react'),
};
const config = {
resolve: {
extensions: ['.js', '.jsx', '.json', '.scss', '.png'],
alias: aliasObj,
modules: [path.resolve(__dirname, 'node_modules')]
},
entry: {
vendor: ['react', 'react-dom', 'react-router-dom', 'prop-types'],
},
output: {
filename: '[name].[hash].js',
path: BUILD_PATH
},
module: {
rules: [
{
test: [/\.jsx$/, /\.js$/],
use: ['babel-loader?cacheDirectory=true'],
exclude: /node_modules/,
include: path.resolve(__dirname, SRC_PATH)
},
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader',
options: {
limit: 8192,
name: 'Img/[name].[ext]',
fallback: 'file-loader'
},
exclude: /node_modules/,
include: path.resolve(__dirname, SRC_PATH)
}
]
},
optimization: {
runtimeChunk: {
name: 'manifest',
},
splitChunks: {
chunks: 'async',
minSize: 30000,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
name: false,
cacheGroups: {
vendor: {
name: 'vendor',
chunks: 'initial',
priority: -10,
reuseExistingChunk: false,
test: /node_modules\/(.*)\.js/,
},
},
},
},
plugins: [
new CleanWebpackPlugin([BUILD_PATH], { verbose: false }),
new HtmlWebpackPlugin({
filename: './index.html',
template: path.resolve(__dirname, './index.html'),
inject: 'body',
chunks: ['vendor', 'main', 'manifest'],
})
],
};
module.exports = config;