Skip to content

Commit e557559

Browse files
committed
moved banner plugin placeholdertesting to separate dir
1 parent e1a2042 commit e557559

10 files changed

Lines changed: 21 additions & 78 deletions

File tree

‎lib/BannerPlugin.js‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1632
class 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
});

‎test/configCases/plugins/banner-plugin/placeholder/index.js‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/placeholder/test.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/placeholder/vendors.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/placeholder/webpack.config.js‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/simple/index.js‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/simple/test.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/simple/vendors.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/simple/webpack.config.js‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎test/configCases/plugins/banner-plugin/webpack.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
},
1414
plugins: [
1515
new webpack.BannerPlugin({
16-
banner: "A test value",
16+
banner: "[hash]",
1717
exclude: ["vendors.js"]
1818
})
1919
]

0 commit comments

Comments
 (0)