Skip to content

emmawilby/rollup-plugin-userscript

 
 

Repository files navigation

rollup-plugin-userscript

NPM License Downloads

Automatically parse metadata and set @grants.

With this plugin, @grants for GM_* functions will be added at compile time.

Usage

Add the plugin to rollup.config.js:

import userscript from 'rollup-plugin-userscript';

const plugins = [
  // ...
  userscript(
    path.resolve('src/meta.js'),
    meta => meta
      .replace('process.env.VERSION', pkg.version)
      .replace('process.env.AUTHOR', pkg.author),
  ),
];

Optional third parameter can be used to append lines to the resulting metadata block (the transform will be applied after concatenation):

import userscript from 'rollup-plugin-userscript';

const plugins = [
  // ...
  userscript(
    path.resolve('src/meta.js'),
    meta => meta
      .replace('process.env.VERSION', pkg.version)
      .replace('process.env.AUTHOR', pkg.author),
    [
      '// @version   process.env.VERSION',
      '// @author    process.env.AUTHOR',
    ]
  ),
];

About

Rollup plugin for userscript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.9%
  • Shell 1.1%