BannerPlugin
为每个chunk文件头部banner
const webpack = require('wepack')
new webpack.BannerPlugin(banner)
// 或者
new webpack.BannerPlugin(options)
选项
{
banner: string | function, // 其值为字符转或函数吧,将作为注释存在
raw: boolean, // 如果为true,将直接输出,不会作为注释
entryOnly: boolean, // 如果值为true,将只在入口chunks文件中添加
include: string | RegExp | [sting, RegExp], // 根据条件匹配所有模块
exclude: string | RegExp | [sting, RegExp], // 根据条件排除所有no
footer?: boolean, // 如果为true,banner将会位于编译结果的最下方
}
用法
// 这样就会在打包后的chunk.js中首部增加一行hello world的注释
new webpack.BannerPlugin({
banner: 'hello world',
});