🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

webpack-userscript

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-userscript

A Webpack4+ plugin for userscript projects.

2.0.0
Source
npm
Version published
Weekly downloads
222
34.55%
Maintainers
1
Weekly downloads
 
Created
Source

webpack-userscript

Build Status JavaScript Style Guide npm Gitmoji

A Webpack4+ plugin for userscript projects.

The package has been renamed from webpack-tampermonkey.

Features

  • Make your userscript development combined with Webpack

    With powerful Webpack support, you can even package everything in your userscript, e.g. icons and json data.

  • Ability to generate userscript headers
  • Ability to generate both .user.js and .meta.js

    .meta.js is used for update check containing headers only.

  • Properly track files in watch mode

    Including external header files and package.json.

Installation

npm i webpack-userscript -D

Usage

webpack.config.js

Include the plugin in the webpack.config.js as the following example.

const WebpackTampermonkey = require('webpack-userscript')

module.exports = {
  plugins: [
    new WebpackTampermonkey()
  ]
}

Examples

Examples can be found under the test fixture folder.

Configuration

WebpackTampermonkey

The WebpackTampermonkey constructor has the following signature.

new WebpackTampermonkey(options)

options

Also see the schema of options.

type WebpackTampermonkeyOptions =
  WPTMOptions |
  HeaderFile |   // shorthand for WPTMOptions.headers
  HeaderProvider // shorthand for WPTMOptions.headers

WPTMOptions

interface WPTMOptions {
  headers: HeaderFile | HeaderProvider

  /**
   * Output *.meta.js or not
   */
  metajs: boolean

  /**
   * Rename all .js files to .user.js files.
   */
  renameExt: boolean

  /**
   * Prettify the header
   */
  pretty: boolean
}

HeaderFile

A path to a js or json file which exports a header object or a header provider function.

type HeaderFile = string

HeaderProvider

A function that returns a header object.

type HeaderProvider = (data: object) => HeaderObject

Note that data contains the same variables as output.filename templates.

HeaderObject

A header object.

Also see explicit-config/webpack.config.js.

type HeaderFile = object

Keywords

webpack

FAQs

Package last updated on 29 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts