1
1
const path = require ( 'path' ) ;
2
2
const webpack = require ( 'webpack' ) ;
3
- const UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' ) ;
3
+ const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
4
+
5
+ const {
6
+ name,
7
+ version,
8
+ repository,
9
+ author,
10
+ license
11
+ } = require ( './package.json' ) ;
4
12
5
13
const isProduction = process . env . NODE_ENV === 'production' ;
6
- const mode = isProduction ? 'production' : 'development' ;
7
14
8
15
const libraryName = 'js-is-type' ;
9
16
17
+ const banner = `
18
+ ${ name } v${ version }
19
+ ${ repository . url }
20
+ Copyright (c) ${ author . replace ( / * \< [ ^ ) ] * \> * / g, ' ' ) }
21
+ This source code is licensed under the ${ license } license found in the
22
+ LICENSE file in the root directory of this source tree.
23
+ ` ;
24
+
10
25
module . exports = {
11
- mode,
26
+ mode : isProduction ? 'production' : 'development' ,
12
27
entry : {
13
28
[ libraryName ] : path . resolve ( __dirname , 'src/index.js' ) ,
14
29
[ `${ libraryName } .min` ] : path . resolve ( __dirname , 'src/index.js' )
15
30
} ,
16
31
devtool : 'source-map' ,
17
32
output : {
18
- path : path . resolve ( __dirname , 'dist' ) ,
19
33
filename : '[name].js' ,
34
+ path : path . resolve ( __dirname , 'dist' ) ,
20
35
library : libraryName ,
21
36
libraryTarget : 'umd' ,
22
- umdNamedDefine : true ,
23
37
globalObject : "typeof self !== 'undefined' ? self : this"
24
38
} ,
25
39
module : {
@@ -38,12 +52,13 @@ module.exports = {
38
52
} ,
39
53
optimization : {
40
54
minimize : true ,
41
- minimizer : [ new UglifyJsPlugin ( { include : / \. m i n \. j s $ / } ) ]
55
+ minimizer : [ new TerserPlugin ( ) ]
42
56
} ,
43
57
plugins : [
44
58
new webpack . DefinePlugin ( {
45
59
'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV )
46
- } )
60
+ } ) ,
61
+ new webpack . BannerPlugin ( banner )
47
62
] ,
48
63
resolve : {
49
64
extensions : [ '.json' , '.js' ]
0 commit comments