Go to file
2020-04-26 05:02:54 +08:00
.github/workflows build: add peerDependencies 2020-04-26 05:01:42 +08:00
src fix: metadata will keep is minify is enabled 2020-04-26 04:43:17 +08:00
.gitignore init 2018-07-28 17:04:10 +08:00
package-lock.json 0.0.6 2020-04-26 05:02:54 +08:00
package.json 0.0.6 2020-04-26 05:02:54 +08:00
readme.md update readme 2018-07-28 17:33:05 +08:00

userscript-metadata-webpack-plugin

userscript-metadata-webpack-plugin is a webpack plugin to generate userscript metadata and prepend to file which name matched *.user.js

Only work with webpack 4

usage

install

npm i userscript-metadata-webpack-plugin -D

configure

webpack.config.js

const pkg = require('../package.json')
const UserScriptMetaDataPlugin = require('userscript-metadata-webpack-plugin')

let metadata = {
  'name': 'UserScript name' || pkg.name,
  'name:zh': '用户脚本名',
  'namespace': pkg.repository.url,
  'version': pkg.version,
  'author': pkg.author, // could be a object { name , email } or string
  'source': pkg.repository.url,
  'license': pkg.license,
  'match': [
    'www.google.com'
  ],
  'require': [
    'https://code.jquery.com/jquery-3.3.1.min.js',
  ],
  'grant': [
    'GM_xmlhttpRequest',
  ],
  'connect': [
    'localhost',
    'www.google.com'
  ],
  'run-at': 'document-end'
}

const config = {
  // ...
  // ...
  plugins: [
    new UserScriptMetaDataPlugin({
      metadata
    })
  ]
}

module.exports = config