@calvin_von/proxy-plugin-inject

1.1.0-beta • Public • Published

proxy-plugin-inject

A dalao-proxy for auto run multiple commands in parallel.

only support dalao-proxy > 1.x

version

Usage

Install dalao-proxy cli first

npm install -g dalao-proxy

Install plugin

  • globally

    $ dalao-proxy plugin install -g @calvin_von/proxy-plugin-inject
  • locally

    $ dalao-proxy plugin install -D @calvin_von/proxy-plugin-inject

Add config

"inject": {
    "rules": [],
    "presets": {
        "mobileConsole": false,
        "remoteConsole": false
    }
}

Start proxy

$ dalao-proxy start
...
> npm run start

Config

rules

Example: inject inject-file.js into all files named index.html

{
    "rules": [
        {
            "test": "^index\.html$",
            "serves": {
                "inject-file.js": "./libs/injected-file.js",
            },
            "template": "<script src=\"{{inject-file.js}}\"></script>",
            "insert": "body"
        }
    ]
}
  • test: A RegExp to test all request over proxy.
  • serves: An Object contains all static files to serve. An inter URL prefix would be added before the given name.
  • template: A DOMString to be inserted into the matched HTML document.
  • templateSrc: A path string of the text file that contains DOMString to be inserted into the matched HTML document.
  • insert: A string tells the plugin where to insert.

presets

  • mobileConsole: Inject a console called eruda for better debugging in mobile browsers
  • remoteConsole: An experimental feature: debugging mobile web applications in the terminal console

more docs about dalao-proxy, see CalvinVon/dalao-proxy on Github.

Package Sidebar

Install

npm i @calvin_von/proxy-plugin-inject

Weekly Downloads

0

Version

1.1.0-beta

License

ISC

Unpacked Size

13.2 kB

Total Files

8

Last publish

Collaborators

  • calvin_von