@calvin_von/proxy-plugin-inject
v1.1.0-beta
Published
A dalao-proxy plugin for inject scripts into html
Downloads
14
Maintainers
Readme
proxy-plugin-inject
A dalao-proxy for auto run multiple commands in parallel.
only support dalao-proxy > 1.x
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 containsDOMString
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.