@@ -2,36 +2,50 @@ const path = require('path');
2
2
const webpack = require ( 'webpack' ) ;
3
3
const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
4
4
5
+ const {
6
+ name,
7
+ version,
8
+ repository,
9
+ author,
10
+ license
11
+ } = require ( './package.json' ) ;
12
+
5
13
const isProduction = process . env . NODE_ENV === 'production' ;
6
- const mode = isProduction ? 'production' : 'development' ;
7
14
8
15
const libraryName = 'logger' ;
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
- devtool : 'source-map' ,
17
31
output : {
18
- path : path . join ( __dirname , 'dist' ) ,
32
+ filename : '[name].js' ,
33
+ path : path . resolve ( __dirname , 'dist' ) ,
19
34
library : libraryName ,
20
35
libraryTarget : 'umd' ,
21
- filename : '[name].js' ,
22
36
globalObject : "typeof self !== 'undefined' ? self : this"
23
37
} ,
24
38
module : {
25
39
rules : [
26
40
{
27
41
test : / \. j s $ / ,
42
+ exclude : / n o d e _ m o d u l e s / ,
28
43
use : {
29
44
loader : 'babel-loader' ,
30
45
options : {
31
46
presets : [ '@babel/preset-env' ]
32
47
}
33
- } ,
34
- exclude : / n o d e _ m o d u l e s /
48
+ }
35
49
}
36
50
]
37
51
} ,
@@ -42,7 +56,8 @@ module.exports = {
42
56
plugins : [
43
57
new webpack . DefinePlugin ( {
44
58
'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV )
45
- } )
59
+ } ) ,
60
+ new webpack . BannerPlugin ( banner )
46
61
] ,
47
62
resolve : {
48
63
extensions : [ '.json' , '.js' ]
0 commit comments