Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding build and clean commands, update readme #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 3 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,12 @@ See the [Node.js Request README][req] for several more examples. Request intends

## Browserify

Browser Request is a [browserify][browserify]-enabled package.
To build Browser Request, run:

First, add `browser-request` to your Node project
npm run build

$ npm install browser-request
a `dist` directory will be created with `request.js` and `request.min.js`.

Next, make a module that uses the package.

```javascript
// example.js - Example front-end (client-side) code using browser-request via browserify
//
var request = require('browser-request')
request('/', function(er, res) {
if(!er)
return console.log('browser-request got your root path:\n' + res.body)

console.log('There was an error, but at least browser-request loaded and ran!')
throw er
})
```

To build this for the browser, run it through browserify.

$ browserify --entry example.js --outfile example-built.js

Deploy `example-built.js` to your web site and use it from your page.

```html
<script src="example-built.js"></script> <!-- Runs the request, outputs the result to the console -->
```
## License

Browser Request is licensed under the Apache 2.0 license.
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
"url": "git://github.com/iriscouch/browser-request"
},
"scripts": {
"test": "beefy test.js"
"test": "beefy test.js",
"build": "mkdir -p dist && browserify index.js -o dist/request.js -s request && cd dist && uglifyjs request.js -o request.min.js",
"clean": "rm -rf dist"
},
"devDependencies": {
"tape": "~1.0.4",
"beefy": "~0.4.0",
"browserify": "~2.25.0"
"browserify": "~2.25.0",
"uglify-js": "~2.4.24"
},
"engines": [
"node"
Expand Down