rollup-plugin-true-banner
v1.0.0
Published
Rollup plugin that truly places the banner at the top of the file
Maintainers
Readme
Rollup plugin to place license from file at the very top of the bundled file. This works even with imports. The true banner.
npm install --save-dev rollup-plugin-true-bannerExample usage
import trueBanner from 'rollup-plugin-true-banner';export default [
{
input: 'index.js',
output: [
{
file: 'index.js',
format: 'es',
sourcemap: false,
}
],
plugins: [
resolve(),
commonjs(),
terser({
mangle: {
reserved: ['autofocus'],
keep_fnames: true,
keep_classnames: true,
},
format: {
comments: /^!/
},
compress: {
keep_fargs: true,
drop_console: true, // Strip console logs
},
}),
trueBanner({
file: 'license'
licenseFile: true
}) // <-- Run after minification and whatnot
],
},
];Example result
let f=(a,b)=>Math.floor(Math.random()*(b-a+1))+a;class P{constructor(n){this.n=n||"X";this.i=f(1e3,9999)}g(){console.log(`Hi, I'm ${this.n} #${this.i}`)}d(){let x=["run","jump","code","sleep"][f(0,3)];console.log(this.n+" is "+x)}}p=new P("Bot");p.g();p.d();w=t=>new Promise(r=>setTimeout(r,t));(async()=>{console.log("Wait...");await w(1e3);console.log("Done")})();
/*! Copyright (c) 1970 John */
console.log(["foo","bar","baz","qux"][Math.floor(Math.random()*4)]);To
/*!
Copyright (c) 1970 John
*/
let f=(a,b)=>Math.floor(Math.random()*(b-a+1))+a;class P{constructor(n){this.n=n||"X";this.i=f(1e3,9999)}g(){console.log(`Hi, I'm ${this.n} #${this.i}`)}d(){let x=["run","jump","code","sleep"][f(0,3)];console.log(this.n+" is "+x)}}p=new P("Bot");p.g();p.d();w=t=>new Promise(r=>setTimeout(r,t));(async()=>{console.log("Wait...");await w(1e3);console.log("Done")})(); console.log(["foo","bar","baz","qux"][Math.floor(Math.random()*4)]);Options
|Option|Value|Functionality|Default| |------|-----|-------------|-------| |file|string (path)|Load license from separate file|null| |licenseFile|boolean|Determines if file is regular text file, for example a license file|false|
licenseFile option looks for comment based license if set to false. If set to true it will read the text from file as is.
