Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guangchen2333/rollup-plugin-userscript-metadata
一个使 Rollup.js 可以通过 JSON 生成 Userscript 头信息的插件 | A Rollup.js plugin that enables automatic generation of userscript metadata from JSON
https://github.com/guangchen2333/rollup-plugin-userscript-metadata
rollup rollup-plugin userscript userscript-development userscript-metadata vite-plugin
Last synced: 9 days ago
JSON representation
一个使 Rollup.js 可以通过 JSON 生成 Userscript 头信息的插件 | A Rollup.js plugin that enables automatic generation of userscript metadata from JSON
- Host: GitHub
- URL: https://github.com/guangchen2333/rollup-plugin-userscript-metadata
- Owner: GuangChen2333
- License: mit
- Created: 2023-10-15T07:17:06.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-06T08:11:19.000Z (12 months ago)
- Last Synced: 2025-01-25T08:34:22.836Z (11 days ago)
- Topics: rollup, rollup-plugin, userscript, userscript-development, userscript-metadata, vite-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/rollup-plugin-userscript-metadata
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup-plugin-userscript-metadata
A Rollup.js plugin that enables automatic generation of userscript metadata from JSON.
## Quick Start
### Installation
#### npm
```shell
npm install --save-dev rollup-plugin-userscript-metadata
```#### pnpm
```shell
pnpm install --save-dev rollup-plugin-userscript-metadata
```#### yarn
```shell
yarn add --dev rollup-plugin-userscript-metadata
```### Usage
Create a `rollup.config.mjs` configuration file and import the plugin:
```js
import metadata from 'rollup-plugin-userscript-metadata';export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'iife'
},
plugins: [
metadata({
metadata: "src/metadata.json"
})
]
};
```Create a `metadata.json` metadata file like this:
```json
{
"name": "my-plugin",
"version": "1.0.0",
"match": [
"https://example.com/",
"https://example.net/"
]
}
```It will generate the metadata into your output file and **auto-align**.
```js
// ==UserScript==
// @name my-plugin
// @version 1.0.0
// @match https://example.com/
// @match https://example.net/
// ==/UserScript==
```#### Using with @rollup/plugin-terser
Here's how you can modify your `rollup.config.mjs` file to include the rollup-plugin-terser plugin and preserve
the metadata:```js
import metadata from "rollup-plugin-userscript-metadata"
import teaser from "@rollup/plugin-terser"export default {
input: 'src/index.js',
output: {
file: 'dist/index.min.js',
format: 'iife'
},
plugins: [
terser({
format: {
comments: [
"/\\/\\/ ==UserScript==\\n(?:\\/\\/ @[^\\n]+\\n)*\\/\\/ ==\\/UserScript==/\n/m"
]
}
}),
metadata({
metadata: "src/metadata.json"
})
]
};
```