{"id":15254645,"url":"https://github.com/guangchen2333/rollup-plugin-userscript-metadata","last_synced_at":"2026-01-03T23:48:12.506Z","repository":{"id":200172497,"uuid":"705151713","full_name":"GuangChen2333/rollup-plugin-userscript-metadata","owner":"GuangChen2333","description":"一个使 Rollup.js 可以通过 JSON 生成 Userscript 头信息的插件 | A Rollup.js plugin that enables automatic generation of userscript metadata from JSON","archived":false,"fork":false,"pushed_at":"2024-02-06T08:11:19.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T05:41:12.328Z","etag":null,"topics":["rollup","rollup-plugin","userscript","userscript-development","userscript-metadata","vite-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rollup-plugin-userscript-metadata","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/GuangChen2333.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-10-15T07:17:06.000Z","updated_at":"2024-10-25T15:42:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"34980d10-35b1-42fc-a64d-1a4b3cf74a48","html_url":"https://github.com/GuangChen2333/rollup-plugin-userscript-metadata","commit_stats":null,"previous_names":["guangchen2333/rollup-plugin-userscript-metadata"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuangChen2333%2Frollup-plugin-userscript-metadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuangChen2333%2Frollup-plugin-userscript-metadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuangChen2333%2Frollup-plugin-userscript-metadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuangChen2333%2Frollup-plugin-userscript-metadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuangChen2333","download_url":"https://codeload.github.com/GuangChen2333/rollup-plugin-userscript-metadata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244825067,"owners_count":20516587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["rollup","rollup-plugin","userscript","userscript-development","userscript-metadata","vite-plugin"],"created_at":"2024-09-29T23:05:24.075Z","updated_at":"2026-01-03T23:48:12.475Z","avatar_url":"https://github.com/GuangChen2333.png","language":"TypeScript","readme":"# rollup-plugin-userscript-metadata\n\nA Rollup.js plugin that enables automatic generation of userscript metadata from JSON.\n\n## Quick Start\n\n### Installation\n\n#### npm\n\n```shell\nnpm install --save-dev rollup-plugin-userscript-metadata\n```\n\n#### pnpm\n\n```shell\npnpm install --save-dev rollup-plugin-userscript-metadata\n```\n\n#### yarn\n\n```shell\nyarn add --dev rollup-plugin-userscript-metadata\n```\n\n### Usage\n\nCreate a `rollup.config.mjs` configuration file and import the plugin:\n\n```js\nimport metadata from 'rollup-plugin-userscript-metadata';\n\nexport default {\n    input: 'src/index.js',\n    output: {\n        dir: 'output',\n        format: 'iife'\n    },\n    plugins: [\n        metadata({\n            metadata: \"src/metadata.json\"\n        })\n    ]\n};\n```\n\nCreate a `metadata.json` metadata file like this:\n\n```json\n{\n  \"name\": \"my-plugin\",\n  \"version\": \"1.0.0\",\n  \"match\": [\n    \"https://example.com/\",\n    \"https://example.net/\"\n  ]\n}\n```\n\nIt will generate the metadata into your output file and **auto-align**.\n\n```js\n// ==UserScript==\n// @name    my-plugin\n// @version 1.0.0\n// @match   https://example.com/\n// @match   https://example.net/\n// ==/UserScript==\n```\n\n#### Using with @rollup/plugin-terser\n\nHere's how you can modify your `rollup.config.mjs` file to include the rollup-plugin-terser plugin and preserve \nthe metadata:\n\n```js\nimport metadata from \"rollup-plugin-userscript-metadata\"\nimport teaser from \"@rollup/plugin-terser\"\n\nexport default {\n    input: 'src/index.js',\n    output: {\n        file: 'dist/index.min.js',\n        format: 'iife'\n    },\n    plugins: [\n        terser({\n            format: {\n                comments: [\n                    \"/\\\\/\\\\/ ==UserScript==\\\\n(?:\\\\/\\\\/ @[^\\\\n]+\\\\n)*\\\\/\\\\/ ==\\\\/UserScript==/\\n/m\"\n                ]\n            }\n        }),\n        metadata({\n            metadata: \"src/metadata.json\"\n        })\n    ]\n};\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguangchen2333%2Frollup-plugin-userscript-metadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguangchen2333%2Frollup-plugin-userscript-metadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguangchen2333%2Frollup-plugin-userscript-metadata/lists"}