@@ -4,6 +4,23 @@ import babel from 'rollup-plugin-babel';
44import { terser } from 'rollup-plugin-terser' ;
55import fs from 'fs' ;
66import path from 'path' ;
7+ import rootpkg from './package.json' ;
8+
9+
10+ let getBanner = name => `/**
11+ * ${ name } ${ rootpkg . version }
12+ * Copyright (C) 2020 ActiveWidgets SARL. All Rights Reserved.
13+ * This code is licensed under the MIT license found in the
14+ * LICENSE file in the root directory of this package.
15+ */
16+ ` ;
17+
18+
19+ function keepBanner ( node , comment ) {
20+ if ( comment . type == "comment2" ) {
21+ return / 2 0 2 0 A c t i v e W i d g e t s / . test ( comment . value ) ;
22+ }
23+ }
724
825
926let plugins = [
@@ -13,7 +30,9 @@ let plugins = [
1330 exclude : 'node_modules/**' ,
1431 presets : [ [ "@babel/env" , { modules : false } ] ]
1532 } ) ,
16- terser ( )
33+ terser ( {
34+ output : { comments : keepBanner }
35+ } )
1736] ;
1837
1938
@@ -29,13 +48,14 @@ function expand({name, input}){
2948 main = path . join ( dir , pkg . main ) ,
3049 module = path . join ( dir , pkg . module ) ,
3150 sourcemap = true ,
51+ banner = getBanner ( pkg . name ) ,
3252 extend = true ;
3353
3454 return {
3555 input,
3656 output : [
37- { file : main , format : 'umd' , sourcemap, name, extend} ,
38- { file : module , format : 'esm' , sourcemap}
57+ { file : main , format : 'umd' , sourcemap, banner , name, extend} ,
58+ { file : module , format : 'esm' , sourcemap, banner }
3959 ] ,
4060 plugins
4161 } ;
0 commit comments