Package Exports
- rollup-plugin-userscript-metadata
- rollup-plugin-userscript-metadata/dist/index.cjs.min.js
- rollup-plugin-userscript-metadata/dist/index.es.min.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-userscript-metadata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rollup-plugin-userscript-metadata
A Rollup.js plugin that enables automatic generation of userscript metadata from JSON.
Quick Start
Installation
npm
npm install --save-dev rollup-plugin-userscript-metadatapnpm
pnpm install --save-dev rollup-plugin-userscript-metadatayarn
yarn add --dev rollup-plugin-userscript-metadataUsage
Create a rollup.config.mjs configuration file and import the plugin:
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:
{
"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.
// ==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:
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"
})
]
};