forked from linagora/esn-frontend-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
68 lines (66 loc) · 2.01 KB
/
webpack.prod.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
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const commons = require('./webpack.commons.js');
module.exports = merge(commons, {
mode: 'production',
devtool: 'source-map',
output: {
filename: '[name].[hash].min.js'
},
module: {
rules: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/esn-frontend-common-libs'),
path.resolve(__dirname, 'node_modules/esn-frontend-calendar'),
path.resolve(__dirname, 'node_modules/esn-frontend-mailto-handler'),
path.resolve(__dirname, 'node_modules/esn-frontend-group'),
path.resolve(__dirname, 'node_modules/esn-frontend-inbox'),
path.resolve(__dirname, 'node_modules/esn-frontend-contacts')
],
exclude: [
path.resolve(__dirname, 'node_modules/esn-frontend-common-libs/src/frontend/components')
],
use: [
{
loader: 'babel-loader'
}
]
}
]
},
plugins: [
new CompressionWebpackPlugin(),
new CleanWebpackPlugin(),
new webpack.ProgressPlugin(),
new webpack.HashedModuleIdsPlugin(),
new webpack.BannerPlugin(`${process.env.npm_package_name} v${process.env.npm_package_version}`)
],
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 200000,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `${packageName.replace('@', '')}`;
}
}
}
},
minimize: true,
minimizer: [
new TerserPlugin()
]
}
});