https://github.com/guangchen2333/rollup-plugin-userscript-boilerplate
一个使 Rollup.js 可以通过 JSON 生成 Userscript 开发时骨架的插件 | A Rollup.js plugin that enables automatic generation of userscript boilerplate from JSON
https://github.com/guangchen2333/rollup-plugin-userscript-boilerplate
rollup rollup-plugin userscript userscript-development vite-plugin
Last synced: 21 days ago
JSON representation
一个使 Rollup.js 可以通过 JSON 生成 Userscript 开发时骨架的插件 | A Rollup.js plugin that enables automatic generation of userscript boilerplate from JSON
- Host: GitHub
- URL: https://github.com/guangchen2333/rollup-plugin-userscript-boilerplate
- Owner: GuangChen2333
- License: mit
- Created: 2023-10-15T13:42:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T08:10:54.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T11:12:29.223Z (12 months ago)
- Topics: rollup, rollup-plugin, userscript, userscript-development, vite-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/rollup-plugin-userscript-boilerplate
- Size: 5.86 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-boilerplate
A Rollup.js plugin that enables automatic generation of userscript boilerplate from JSON
## Quick Start
### Installation
#### npm
```shell
npm install --save-dev rollup-plugin-userscript-boilerplate
```
#### pnpm
```shell
pnpm install --save-dev rollup-plugin-userscript-boilerplate
```
#### yarn
```shell
yarn add --dev rollup-plugin-userscript-boilerplate
```
### Usage
Create a `rollup.config.mjs` configuration file and import the plugin:
```js
import boilerplate from 'rollup-plugin-userscript-boilerplate';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'iife'
},
plugins: [
boilerplate({
// Metadata path
metadata: "src/metadata.json",
// Your source script (like iife format)
source: "src/index.js",
// Output path
output: "output/dev.user.js"
})
]
};
```
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 boilerplate to your path.
```js
// ==UserScript==
// @name my-plugin
// @version 1.0.0
// @match https://example.com/
// @match https://example.net/
// @require file:///example/output/{SOURCE}.js
// ==/UserScript==
```