forked from ip-tools/patzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.release.config.js
105 lines (92 loc) · 2.89 KB
/
webpack.release.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
// -*- coding: utf-8 -*-
// (c) 2017-2018 Andreas Motl <andreas.motl@ip-tools.org>
var os = require('os');
const config = require('./webpack.config');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
// Signal minified resource names
config.output.filename = '[name].bundle.min.js';
// https://www.npmjs.com/package/sourcemapped-stacktrace
// https://webpack.js.org/configuration/devtool/
// https://webpack.js.org/plugins/source-map-dev-tool-plugin/
config.devtool = "source-map";
// Apply code splitting
// https://webpack.js.org/guides/code-splitting/
// https://gist.github.com/sokra/1522d586b8e5c0f5072d7565c2bee693
config.optimization.splitChunks = {
cacheGroups: {
commons: {
//test: /[\\/]node_modules[\\/]/,
name: "commons",
filename: "commons.bundle.min.js",
chunks: "initial",
minChunks: 3,
reuseExistingChunk: true,
}
}
};
config.plugins.push(
// TODO: Serve static .gz files via Nginx
// https://github.com/webpack-contrib/compression-webpack-plugin
// https://github.com/zeit/next.js/issues/1446#issuecomment-317359011
// https://medium.com/smartboxtv-engineering/optimizing-loading-time-for-big-react-apps-cf13bbf63c57
/*
new CompressionPlugin({
cache: true,
})
*/
// https://webpack.js.org/plugins/define-plugin/
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
})
);
config.optimization.minimizer = [
// https://webpack.js.org/plugins/uglifyjs-webpack-plugin/
new UglifyJsPlugin({
sourceMap: true,
cache: true,
parallel: true,
/*
uglifyOptions: {
ie8: false,
compress: {
passes: 2,
//toplevel: true,
warnings: false,
properties: true,
sequences: true,
dead_code: true,
conditionals: true,
comparisons: true,
evaluate: true,
booleans: true,
unused: true,
loops: true,
hoist_funs: true,
hoist_props: true,
hoist_vars: true,
//cascade: true,
if_return: true,
join_vars: true,
drop_console: false,
drop_debugger: true,
//unsafe: true,
negate_iife: true,
//side_effects: true
},
mangle: {
//toplevel: true,
//sort: true,
//eval: true,
properties: true
},
output: {
comments: false,
beautify: false,
},
},
*/
})
];
module.exports = config;