11const webpack = require ( "webpack" ) ;
22const path = require ( "path" ) ;
3- const UglifyJsPlugin = require ( "uglifyjs -webpack-plugin" ) ;
3+ const TerserPlugin = require ( "terser -webpack-plugin" ) ;
44
55module . exports = env => {
6-
76 if ( ! env ) env = { production : false , karma : false } ;
87
98 let mode = env . production ? "production" : "development" ;
109 let tsconfig = ! env . karma ? "tsconfig.json" : "tsconfig.test.json" ;
1110 let output = env . production ? "dist" : "dist-test" ;
12- let filename = env . karma ? "[name].[hash].js" : ( env . production ? "robotlegs-signalcommandmap.min.js" : "robotlegs-signalcommandmap.js" ) ;
11+ let filename = env . karma ? "[name].[hash].js" : env . production ? "robotlegs-signalcommandmap.min.js" : "robotlegs-signalcommandmap.js" ;
1312
1413 return {
1514 mode : mode ,
@@ -35,9 +34,7 @@ module.exports = env => {
3534 loader : "ts-loader?configFile=" + tsconfig
3635 } ,
3736 {
38- test : ( ( env . production ) /* disable this loader for production builds */
39- ? / ^ $ /
40- : / ^ .* ( s r c ) .* \. t s $ / ) ,
37+ test : env . production /* disable this loader for production builds */ ? / ^ $ / : / ^ .* ( s r c ) .* \. t s $ / ,
4138 loader : "istanbul-instrumenter-loader" ,
4239 query : {
4340 embedSource : true
@@ -47,34 +44,27 @@ module.exports = env => {
4744 ]
4845 } ,
4946
50- plugins : (
51- ( env . production )
52- ? [ ]
53- : [ new webpack . SourceMapDevToolPlugin ( { test : / \. t s $ / i } ) ]
54- ) ,
47+ plugins : env . production ? [ ] : [ new webpack . SourceMapDevToolPlugin ( { test : / \. t s $ / i } ) ] ,
5548
56- optimization :
57- ( env . production )
58- ? {
59- concatenateModules : true ,
60- minimize : true ,
61- minimizer : [
62- new UglifyJsPlugin ( {
63- cache : true ,
64- parallel : 4 ,
65- uglifyOptions : {
66- output : {
67- comments : false
68- }
49+ optimization : env . production
50+ ? {
51+ concatenateModules : true ,
52+ minimize : true ,
53+ minimizer : [
54+ new TerserPlugin ( {
55+ cache : true ,
56+ parallel : 4 ,
57+ terserOptions : {
58+ output : {
59+ comments : false
6960 }
70- } )
71- ]
72- }
73- : { }
74- ,
75-
61+ }
62+ } )
63+ ]
64+ }
65+ : { } ,
7666 resolve : {
7767 extensions : [ ".ts" , ".js" , ".json" ]
7868 }
79- }
69+ } ;
8070} ;
0 commit comments