@@ -13,6 +13,22 @@ function wrapComment(str) {
1313 return `/*!\n * ${ str . split ( "\n" ) . join ( "\n * " ) } \n */` ;
1414}
1515
16+ /*The following tokens are replaced in the name parameter:
17+ *
18+ *[ext] the extension of the resource
19+ *[name] the basename of the resource
20+ *[path] the path of the resource relative to the context query parameter or option.
21+ *[folder] the folder of the resource is in.
22+ *[emoji] a random emoji representation of options.content
23+ *[emoji:<length>] same as above, but with a customizable number of emojis
24+ *[hash] the hash of options.content (Buffer) (by default it's the hex digest of the md5 hash)
25+ *[<hashType>:hash:<digestType>:<length>] optionally one can configure
26+ *other hashTypes, i. e. sha1, md5, sha256, sha512
27+ *other digestTypes, i. e. hex, base26, base32, base36, base49, base52, base58, base62, base64
28+ *and length the length in chars
29+ *[N] the N-th match obtained from matching the current file name against options.regExp
30+ */
31+
1632class BannerPlugin {
1733 constructor ( options ) {
1834 if ( arguments . length > 1 )
@@ -30,17 +46,18 @@ class BannerPlugin {
3046 const banner = this . banner ;
3147
3248 compiler . plugin ( "compilation" , ( compilation ) => {
49+ console . log ( 'compilation: ' , compilation ) ;
3350 compilation . plugin ( "optimize-chunk-assets" , ( chunks , callback ) => {
3451 chunks . forEach ( ( chunk ) => {
3552 if ( options . entryOnly && ! chunk . isInitial ( ) ) return ;
3653
3754 chunk . files
3855 . filter ( ModuleFilenameHelpers . matchObject . bind ( undefined , options ) )
39- . forEach ( ( file ) =>
40- compilation . assets [ file ] = new ConcatSource (
56+ . forEach ( ( file ) => {
57+ return compilation . assets [ file ] = new ConcatSource (
4158 banner , "\n" , compilation . assets [ file ]
4259 )
43- ) ;
60+ } ) ;
4461 } ) ;
4562 callback ( ) ;
4663 } ) ;
0 commit comments