1.1.0-beta • Published 1 year ago
@calvin_von/proxy-plugin-inject v1.1.0-beta
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-proxyInstall plugin
globally
$ dalao-proxy plugin install -g @calvin_von/proxy-plugin-injectlocally
$ 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 startConfig
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
RegExpto test all request over proxy. - serves: An
Objectcontains all static files to serve. An inter URL prefix would be added before the given name. - template: A
DOMStringto be inserted into the matched HTML document. - templateSrc: A path
stringof the text file that containsDOMStringto be inserted into the matched HTML document. - insert: A
stringtells 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.