1
1
const path = require ( 'path' ) ;
2
2
3
- const webpack = require ( 'webpack' ) ;
4
3
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
5
4
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
6
5
const UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' ) ;
@@ -11,14 +10,10 @@ const phaser = path.join(phaserModule, 'build/custom/phaser-arcade-physics.js');
11
10
const pixi = path . join ( phaserModule , 'build/custom/pixi.js' ) ;
12
11
const p2 = path . join ( phaserModule , 'build/custom/p2.js' ) ;
13
12
const howler = path . join ( __dirname , '/node_modules/howler/dist/howler.min.js' ) ;
14
- const vendorPackages = / p h a s e r - c e | p h a s e r - a r c a d e - p h y s i c s | h o w l e r | p i x i | p 2 / ;
15
13
16
14
module . exports = {
17
15
entry : {
18
- vendor : [ 'pixi' , 'p2' , 'phaser' , 'howler' ] ,
19
- app : [
20
- path . resolve ( __dirname , 'src/app.ts' )
21
- ]
16
+ app : path . resolve ( __dirname , 'src/app.ts' )
22
17
} ,
23
18
output : {
24
19
filename : '[name].bundle.js' ,
@@ -32,38 +27,35 @@ module.exports = {
32
27
to : './assets'
33
28
}
34
29
] ) ,
35
- new webpack . optimize . CommonsChunkPlugin ( {
36
- name : "vendor" ,
37
- minChunks : function ( module , count ) {
38
- return module . resource && vendorPackages . test ( module . resource ) && count >= 1 ;
39
- }
40
- } ) ,
41
- new UglifyJsPlugin ( {
42
- uglifyOptions : {
43
- mangle : true ,
44
- drop_console : true ,
45
- minimize : true
46
- } ,
47
- output : {
48
- comments : false ,
49
- beautify : false
50
- }
51
- } ) ,
52
30
new JavaScriptObfuscator ( {
53
31
rotateUnicodeArray : true
54
32
} , [ 'vendor.bundle.js' ] ) ,
55
33
new HtmlWebpackPlugin ( {
56
34
template : './index.html' ,
57
- inject : 'body'
35
+ inject : 'body' ,
58
36
} )
59
37
] ,
38
+ optimization : {
39
+ splitChunks : {
40
+ cacheGroups : {
41
+ vendor : {
42
+ test : / n o d e _ m o d u l e s / ,
43
+ chunks : "initial" ,
44
+ name : "vendor" ,
45
+ priority : 10 ,
46
+ enforce : true
47
+ }
48
+ }
49
+ } ,
50
+ minimizer : [ new UglifyJsPlugin ( ) ] ,
51
+ } ,
60
52
module : {
61
- loaders : [
62
- { test : / \. t s ? $ / , loader : 'ts-loader' , exclude : '/node_modules/' } ,
63
- { test : / p i x i \. j s / , use : [ 'expose-loader?PIXI' ] } ,
64
- { test : / p h a s e r - a r c a d e - p h y s i c s \. j s / , use : [ 'expose-loader?Phaser' ] } ,
65
- { test : / h o w l e r \. m i n \. j s / , use : [ 'expose-loader?Howler' ] } ,
66
- { test : / p 2 \. j s $ / , use : [ 'expose-loader?p2' ] }
53
+ rules : [
54
+ { test : / \. t s ? $ / , loader : 'ts-loader' , exclude : '/node_modules/' } ,
55
+ { test : / p i x i \. j s / , loader : 'expose-loader?PIXI' } ,
56
+ { test : / p h a s e r - a r c a d e - p h y s i c s \. j s / , loader : 'expose-loader?Phaser' } ,
57
+ { test : / h o w l e r \. m i n \. j s / , loader : 'expose-loader?Howler' } ,
58
+ { test : / p 2 \. j s $ / , loader : 'expose-loader?p2' }
67
59
]
68
60
} ,
69
61
resolve : {
0 commit comments