Skip to content

Commit

Permalink
reduced the size of browser bundle, fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Braydon Fuller committed Oct 21, 2014
1 parent 1bddf91 commit a697dcc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist/bitauth.browser.js
dist/bitauth.browser.min.js
dist/bitauth.bundle.js
dist/bitcore.bundle.js
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,24 @@ app.use( bitauth.middleware );

## Development

To run tests for Node.js:
To build a browser compatible version of BitAuth, run the following command from the project's root directory:

```bash
npm run test
```
npm run make-dist
```

To run tests for a web browser:
This will output `bitauth.browser.min.js` to the `dist` directory. The script introduces a global variable at `window.bitauth`.

```bash
npm run make-dist

firefox $PWD/test/index.html
chromium-browser $PWD/test/index.html
To then run tests for a web browser open `test/index.html` in a browser, such as:

```bash
firefox test/index.html
chromium-browser test/index.html
```

Or open the file directly from a web browser.
To run tests for Node.js:

```bash
npm run test
```
11 changes: 0 additions & 11 deletions dist/README.md

This file was deleted.

9 changes: 9 additions & 0 deletions dist/bitauth.browser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"devDependencies": {
"uglify-js": "~2.4.14",
"browserify": "~4.1.11",
"browserify": "=6.1.0",
"chai": "=1.9.1",
"mocha": "~1.20.1"
}
Expand Down
11 changes: 5 additions & 6 deletions scripts/make-dist.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
cd node_modules/bitcore
echo "Building browser bundle for bitcore..."
node browser/build -s lib/Key,lib/SINKey,lib/SIN,util/util
echo "Building browser bundle for bitauth..."
cd ../../
node_modules/.bin/browserify lib/bitauth.js -s bitauth -x buffertools -i bitcore -o dist/bitauth.browser.js
echo "Compiling bitcore and bitauth..."
node_modules/.bin/uglifyjs node_modules/bitcore/browser/bundle.js dist/bitauth.browser.js -b -o dist/bitauth.browser.js
echo "Minifying bundle..."
node_modules/.bin/uglifyjs dist/bitauth.browser.js -o dist/bitauth.browser.min.js
cp node_modules/bitcore/browser/bundle.js dist/bitcore.bundle.js
echo "Building browser bundle for bitauth..."
browserify lib/bitauth.js -s bitauth -x buffertools -x bitcore -o dist/bitauth.bundle.js
echo "Minifying bitcore and bitauth..."
node_modules/.bin/uglifyjs dist/bitcore.bundle.js dist/bitauth.bundle.js -o dist/bitauth.browser.min.js
echo "Done!"

0 comments on commit a697dcc

Please sign in to comment.