Proxy while applying amazing transformations
Installation:
$ npm install jproxy -g
Usage:
$ jproxy
Configuration:
See "Proxy Configuration"
Installation:
$ npm install jproxy
Usage:
var jproxy = require('jproxy');
var express = require('express');
var app = express();
var config = {browserify: true};//see "Proxy Configuration" for more info
app.use(jproxy(__dirname, config));
app.listen(3000);
The Proxy Configuration must be a JSON object.
If you're using the API you pass it in: jproxy(dirname, config)
. If you're using the command line you can put it in one of three places.
If you're using the command line interface you can put it in any of the following locations (in this order of precedence).
.jproxy.json
"jproxy"
property inpackage.json
"jproxy"
property incomponent.json
If you're using this in jepso-ci you can put it in any of the 3 locations above, or you can put it in any of the 3 locations below. The ones below take precence:
"proxy"
property in.jepxo-ci.json
"proxy"
property in"jepso-ci"
object inpackage.json
"proxy"
property in"jepso-ci"
object incomponent.json
Each property of the object must correspond to one of the possible jproxy filters. The value of such a proxy must be a FilterConfiguration
or array of FilterConfiguration
s. e.g.
{
"browserify": {
"include": "*.js",
"exclude": "*mocha.js",
"options" {
"transform": ["coffeeify"]
}
},
"uglify-js": [
{
"include": "*.js",
"exclude": "*.min.js",
"options" {
"beautify": true
}
},
{
"include": "*.min.js",
"options" {
"beautify": false
}
}
]
}
The filter configuration is an object which defines when the filter is applied, and how it is applied.
The Filter Configuration consists of the following 3 properties.
- include
- exclude
- options
Include specifies which files to filter. It can be a string, or an array of strings. If the path contains a *
it is treated as "any character one or more times". If the path begins with a /
character, the whole path is required to match. If it begins with anything else it is assumed to just require the end of the path to match.
The filter may define a default include
pattern. If it doesn't, the default will simply be "*".
e.g.
Pattern | Value | Matches |
---|---|---|
"/build/build.js" | "/build/build.js" | TRUE |
"/build/build.js" | "/lib/build/build.js" | FALSE |
"build/build.js" | "/build/build.js" | TRUE |
"build/build.js" | "/lib/build/build.js" | TRUE |
"/build/build.js" | "/build/foo.js" | FALSE |
"/build/*.js" | "/lib/build/foo.js" | TRUE |
Exclude can again be a string, or an array of strings. It overrides include
so if a path matches exclude
it won't be filtered even if it matches include
. By default, everything is excluded.
Options is a JSON object, it's meaning is specific to the individual filter. If omitted the filter will define defaults.