-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.prod.config.js
More file actions
executable file
·119 lines (116 loc) · 2.57 KB
/
Copy pathwebpack.prod.config.js
File metadata and controls
executable file
·119 lines (116 loc) · 2.57 KB
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
109
110
111
112
113
114
115
116
117
118
119
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const JavaScriptObfuscator = require('webpack-obfuscator');
const TerserPlugin = require('terser-webpack-plugin');
const phaserModule = path.join(__dirname, '/node_modules/phaser-ce/');
const phaser = path.join(phaserModule, 'build/custom/phaser-arcade-physics.js');
const pixi = path.join(phaserModule, 'build/custom/pixi.js');
const p2 = path.join(phaserModule, 'build/custom/p2.js');
module.exports = {
entry: {
app: [
path.resolve(pixi),
path.resolve(p2),
path.resolve(__dirname, 'src/app.ts'),
]
},
output: {
filename: '[name].bundle.js',
path: path.resolve('./dist'),
publicPath: '/'
},
mode: 'production',
devtool: false,
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: './assets', to: './assets' },
],
options: {
concurrency: 100,
},
}),
new JavaScriptObfuscator({
rotateUnicodeArray: true
}, ['vendor.bundle.js']),
new HtmlWebpackPlugin({
template: './index.html',
inject: 'body',
})
],
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000,
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: 'initial',
name: 'vendor',
priority: 10,
enforce: true
}
}
},
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
},
}),
],
},
module: {
rules: [
{
test: /\.(j|t)s$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
}
},
{
test: /pixi\.js/,
use: {
loader: 'expose-loader',
options: {
exposes: ['PIXI', pixi]
}
}
},
{
test: /p2\.js$/,
use: {
loader: 'expose-loader',
options: {
exposes: ['p2', p2]
}
}
},
{
test: /phaser-arcade-physics\.js/,
use: {
loader: 'expose-loader',
options: {
exposes: ['Phaser', phaser]
}
}
},
]
},
resolve: {
extensions: ['.js', '.ts'],
alias: {
'phaser-ce': phaser,
'pixi': pixi,
'p2': p2,
}
}
};