New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tiny-webpack-userscript-plugin

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-webpack-userscript-plugin

A tiny plugin to create Tampermonkey/Greasemonkey userscripts with webpack

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Tiny Webpack Userscript Plugin

  • Allows one to bundle userscripts, using webpack
  • It's one file: TinyWebpackUserscriptPlugin.ts

Usage

Check out the test project ./test/webpack.config.ts for a full example!

This could be your webpack.config:

import { resolve } from 'path';
import { TinyWebpackUserscriptPlugin } from 'tiny-webpack-userscript-plugin';

const buildDirectory = resolve(__dirname, './build');
const scriptName = 'TestScript';

export default {
  mode: "development",
  entry: `./${scriptName}.ts`,
  plugins: [
    new TinyWebpackUserscriptPlugin({
      scriptName,
      headers: [
        {
          name: scriptName,
          author: 'jim',
          license: 'MIT',
          namespace: 'jim',
          version: '0.1.0',
          updateURL: `http://github.com/nfour/tiny-webpack-userscript-plugin/master/tree/test/build/${scriptName}.user.js`,
          downloadURL: `http://github.com/nfour/tiny-webpack-userscript-plugin/master/tree/test/build/${scriptName}.user.js`,
        }
      ],
      developmentUrl: 'http://localhost:9002',
    })
  ],
  output: {
    path: buildDirectory,
    filename: `${scriptName}.user.js`
  },
  resolve: { extensions: ['.ts', '.js'] },
  module: {
    rules: [{
      test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/
    }]
  },
};

Tip: To produce multiple scripts, just export an array of webpack configs.

Development tips

To compile and serve your userscripts at, for at http://localhost:9002/${scriptName}.user.js create a npm script like this:

{
  "scripts": {
    "dev": "concurrently 'yarn webpack --watch' 'yarn serve -l 9002 build'"   
  },
  "devDependencies": {
    "concurrently": "5.1",
    "serve": "11.3"
  }
}

Keywords

webpack

FAQs

Package last updated on 22 Mar 2020

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