@@ -2,36 +2,50 @@ const path = require('path');
22const webpack = require ( 'webpack' ) ;
33const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
44
5+ const {
6+ name,
7+ version,
8+ repository,
9+ author,
10+ license
11+ } = require ( './package.json' ) ;
12+
513const isProduction = process . env . NODE_ENV === 'production' ;
6- const mode = isProduction ? 'production' : 'development' ;
714
815const libraryName = 'logger' ;
916
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+
1025module . exports = {
11- mode,
26+ mode : isProduction ? 'production' : 'development' ,
1227 entry : {
1328 [ libraryName ] : path . resolve ( __dirname , 'src/index.js' ) ,
1429 [ `${ libraryName } .min` ] : path . resolve ( __dirname , 'src/index.js' )
1530 } ,
16- devtool : 'source-map' ,
1731 output : {
18- path : path . join ( __dirname , 'dist' ) ,
32+ filename : '[name].js' ,
33+ path : path . resolve ( __dirname , 'dist' ) ,
1934 library : libraryName ,
2035 libraryTarget : 'umd' ,
21- filename : '[name].js' ,
2236 globalObject : "typeof self !== 'undefined' ? self : this"
2337 } ,
2438 module : {
2539 rules : [
2640 {
2741 test : / \. j s $ / ,
42+ exclude : / n o d e _ m o d u l e s / ,
2843 use : {
2944 loader : 'babel-loader' ,
3045 options : {
3146 presets : [ '@babel/preset-env' ]
3247 }
33- } ,
34- exclude : / n o d e _ m o d u l e s /
48+ }
3549 }
3650 ]
3751 } ,
@@ -42,7 +56,8 @@ module.exports = {
4256 plugins : [
4357 new webpack . DefinePlugin ( {
4458 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV )
45- } )
59+ } ) ,
60+ new webpack . BannerPlugin ( banner )
4661 ] ,
4762 resolve : {
4863 extensions : [ '.json' , '.js' ]
0 commit comments