-
Notifications
You must be signed in to change notification settings - Fork 44
/
webpack.config.js
108 lines (105 loc) · 2.96 KB
/
webpack.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
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { dependencies } = require('./package.json');
const coreJsVersion = dependencies['core-js'].replace('^', '');
// Customise a build with (for example):
// yarn webpack --env no-polyfills
// yarn webpack --env modern
// yarn webpack --env public-path=/public/path/to/genoverse
module.exports = (env) => {
const noPolyfills = env.modern || env['no-polyfills'];
return {
mode : 'production',
name : 'genoverse',
target : env.modern ? 'web' : [ 'web', 'es5' ],
entry : [
noPolyfills ? false : `${__dirname}/src/js/lib/polyfills`,
`${__dirname}/src/js/Genoverse`,
].filter(Boolean),
output: {
filename : 'genoverse.js',
path : `${__dirname}/dist`,
...(env['public-path'] ? { publicPath: env['public-path'] } : {}),
},
devtool : 'source-map',
plugins : [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(),
],
optimization: {
minimizer: [
new TerserPlugin({
extractComments : false,
parallel : true,
terserOptions : {
compress: {
keep_infinity: true,
},
output: {
comments: false,
},
},
}),
],
},
performance: {
maxEntrypointSize : 500000,
maxAssetSize : 500000,
},
module: {
rules: [
{
test : /\.png/,
type : 'asset/resource',
},
{
test : /\.css$/i,
use : [
MiniCssExtractPlugin.loader,
'css-loader',
],
},
env.modern
? false
: {
test : /\.js$/,
exclude : [ /node_modules/, /jquery-plugins/ ],
use : {
loader : 'babel-loader',
options : {
presets: [
[
'@babel/preset-env',
{
useBuiltIns : 'entry',
corejs : coreJsVersion,
forceAllTransforms : true,
targets : { ie: 11 },
exclude : [
// The existence of following polyfills result a big performance hit in IE11, so are excluded.
'es.array.splice',
'es.array.concat',
'es.array.filter',
],
},
],
],
},
},
},
].filter(Boolean),
},
devServer: {
static: {
directory: __dirname,
},
client: {
overlay: {
errors : true,
warnings : false,
},
},
},
};
};