{"id":20875871,"url":"https://github.com/saqqdy/rollup-plugin-add-banner","last_synced_at":"2026-04-01T23:03:40.736Z","repository":{"id":57688969,"uuid":"475072435","full_name":"saqqdy/rollup-plugin-add-banner","owner":"saqqdy","description":"A Rollup plugin that adds banner comments to the output bundle.","archived":false,"fork":false,"pushed_at":"2026-03-22T07:36:44.000Z","size":1789,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-22T22:20:57.664Z","etag":null,"topics":["banner","bundler","comment","header","license","prepend","rollup","rollup-plugin","sourcemap","typescript","vite"],"latest_commit_sha":null,"homepage":"https://www.saqqdy.com/rollup-plugin-add-banner","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saqqdy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["saqqdy"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-03-28T15:50:48.000Z","updated_at":"2026-03-22T07:36:47.000Z","dependencies_parsed_at":"2025-05-12T15:37:48.072Z","dependency_job_id":"71fa47c6-1ef6-4ad7-ba1e-8f3b2c8d02bb","html_url":"https://github.com/saqqdy/rollup-plugin-add-banner","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/saqqdy/rollup-plugin-add-banner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Frollup-plugin-add-banner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Frollup-plugin-add-banner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Frollup-plugin-add-banner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Frollup-plugin-add-banner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saqqdy","download_url":"https://codeload.github.com/saqqdy/rollup-plugin-add-banner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Frollup-plugin-add-banner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["banner","bundler","comment","header","license","prepend","rollup","rollup-plugin","sourcemap","typescript","vite"],"created_at":"2024-11-18T06:48:54.212Z","updated_at":"2026-04-01T23:03:40.731Z","avatar_url":"https://github.com/saqqdy.png","language":"TypeScript","funding_links":["https://github.com/sponsors/saqqdy"],"categories":[],"sub_categories":[],"readme":"# rollup-plugin-add-banner\n\n[![NPM version][npm-image]][npm-url]\n[![npm download][download-image]][download-url]\n[![License][license-image]][license-url]\n\nA Rollup plugin that adds banner comments to the output bundle.\n\n[简体中文](./README_CN.md) | [Docs](https://saqqdy.github.io/rollup-plugin-add-banner/)\n\n## Features\n\n- **Template Variables**: Auto-resolve `${name}`, `${version}`, `${author}`, `${license}` from package.json\n- **Custom Variables**: Define your own template variables\n- **Multiple Banners**: Different banners for different file types (`.js`, `.css`, `.mjs`, etc.)\n- **Include/Exclude**: Fine-grained control with glob patterns\n- **File Support**: Read banner from external file\n- **Conditional**: Environment-based banner control\n- **SourceMap**: Full source map support\n- **Plugin API**: Access banner info at runtime\n\n## Installation\n\n```bash\n# pnpm\npnpm add -D rollup-plugin-add-banner\n\n# npm\nnpm install -D rollup-plugin-add-banner\n```\n\n## Usage\n\n```js\nimport addBanner from 'rollup-plugin-add-banner'\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/index.js',\n    format: 'es'\n  },\n  plugins: [\n    addBanner({\n      content: '/*! ${name} v${version} (c) ${author} */'\n    })\n  ]\n}\n```\n\n## Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `content` | `string` | `''` | Banner content (supports template variables) |\n| `file` | `string` | - | Path to file containing banner (overrides `content`) |\n| `vars` | `object` | `{}` | Custom template variables |\n| `include` | `string \\| string[]` | - | Files to include (glob patterns) |\n| `exclude` | `string \\| string[]` | `[]` | Files to exclude (glob patterns) |\n| `banners` | `object` | - | Multiple banners by file type |\n| `envVar` | `string` | - | Environment variable for conditional banner |\n| `envValue` | `string` | `'true'` | Expected value for env var |\n| `pkgPath` | `string` | `'package.json'` | Custom package.json path |\n\n## Template Variables\n\nThe following variables are automatically resolved from `package.json`:\n\n| Variable | Description |\n|----------|-------------|\n| `${name}` | Package name |\n| `${version}` | Package version |\n| `${author}` | Package author |\n| `${license}` | Package license |\n\nYou can also define custom variables:\n\n```js\naddBanner({\n  content: '/*! ${name} v${version} - ${year} */',\n  vars: { year: '2024' }\n})\n```\n\n## Examples\n\n### Basic Usage\n\n```js\naddBanner({\n  content: '/*! ${name} v${version} (c) ${author} */'\n})\n// Output: /*! rollup-plugin-add-banner v2.0.1 (c) saqqdy */\n```\n\n### Multi-line Banner\n\n```js\naddBanner({\n  content: `\n/*!\n * ${name} v${version}\n * (c) ${author}\n * Released under the ${license} License.\n */`\n})\n```\n\n### Banner from File\n\n```js\naddBanner({\n  file: './banner.txt'\n})\n```\n\n### Multiple Banners for Different File Types\n\n```js\naddBanner({\n  banners: {\n    '.js': '/*! ${name} v${version} */',\n    '.mjs': '/*! ${name} v${version} - ESM */',\n    '.css': '/* ${name} v${version} */'\n  }\n})\n```\n\n### Include/Exclude Patterns\n\n```js\naddBanner({\n  content: '/*! ${name} */',\n  include: ['**/*.js', '**/*.mjs'],  // Only .js and .mjs files\n  exclude: ['**/*.min.js']           // Exclude minified files\n})\n```\n\nSupported pattern types:\n- `**/*.js` - Extension match\n- `src/**` - Prefix match\n- `**/dist/**` - Directory match\n- `*.min.js` - Wildcard match\n\n### Conditional Banner (Environment-based)\n\nOnly add banner in production:\n\n```js\naddBanner({\n  content: '/*! ${name} v${version} */',\n  envVar: 'NODE_ENV',\n  envValue: 'production'\n})\n```\n\n### Custom package.json Path\n\n```js\naddBanner({\n  content: '/*! ${name} v${version} */',\n  pkgPath: '../package.json'\n})\n```\n\n## Plugin API\n\nThe plugin exposes an API for runtime access:\n\n```js\nconst plugin = addBanner({ content: '/* banner */' })\n\n// Get resolved default banner\nplugin.api.getBanner() // '/* banner */'\n\n// Get all banners map (if using banners option)\nplugin.api.getBanners() // { '.js': '/* ... */' }\n\n// Get all template variables\nplugin.api.getVars() // { name: '...', version: '...', ... }\n\n// Check if banner should be added (based on envVar)\nplugin.api.shouldAddBanner() // true/false\n```\n\n## Integration Examples\n\n### With Vite\n\n```js\n// vite.config.js\nimport addBanner from 'rollup-plugin-add-banner'\n\nexport default {\n  plugins: [\n    addBanner({\n      content: '/*! ${name} v${version} */'\n    })\n  ]\n}\n```\n\n### With Rollup\n\n```js\n// rollup.config.js\nimport addBanner from 'rollup-plugin-add-banner'\n\nexport default {\n  input: 'src/index.js',\n  output: [\n    { file: 'dist/index.js', format: 'cjs' },\n    { file: 'dist/index.mjs', format: 'es' }\n  ],\n  plugins: [\n    addBanner({\n      banners: {\n        '.js': '/*! ${name} v${version} - CJS */',\n        '.mjs': '/*! ${name} v${version} - ESM */'\n      }\n    })\n  ]\n}\n```\n\n## Requirements\n\n- Rollup \u003e= 2.0.0\n- Node.js \u003e= 12\n\n## Migration from v1 to v2\n\nVersion 2.0.0 includes breaking changes:\n\n1. **Output file paths changed**:\n   - ESM: `dist/index.esm.js` → `dist/index.mjs`\n   - CJS: `dist/index.js` → `dist/index.cjs`\n\n2. **New features available**:\n   - Template variables (no need to read package.json manually)\n   - Include/exclude patterns\n   - Multiple banners support\n   - Environment-based conditional banners\n\n**Before (v1)**:\n\n```js\nimport { readFileSync } from 'node:fs'\nconst pkg = JSON.parse(readFileSync('package.json', 'utf-8'))\n\naddBanner({\n  content: `/*! ${pkg.name} v${pkg.version} */`\n})\n```\n\n**After (v2)**:\n\n```js\naddBanner({\n  content: '/*! ${name} v${version} */'\n})\n```\n\n## Feedback\n\nIf you have any questions or suggestions, please open an [Issue](https://github.com/saqqdy/rollup-plugin-add-banner/issues).\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/rollup-plugin-add-banner.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/rollup-plugin-add-banner\n[download-image]: https://img.shields.io/npm/dm/rollup-plugin-add-banner.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rollup-plugin-add-banner\n[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg\n[license-url]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaqqdy%2Frollup-plugin-add-banner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaqqdy%2Frollup-plugin-add-banner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaqqdy%2Frollup-plugin-add-banner/lists"}