Skip to content

Commit

Permalink
build: build deployment and distributable usage (dashpay#174)
Browse files Browse the repository at this point in the history
* fix: dist being excluded by gitignore

* docs: specified unpkg usage

* build: removed rawConfig + fix .txt extracted as file

output were mangled anyway, so usage of it is reduced. Therefore we remove it.

* docs: added usage example for web

* chore: build before publishing

Allow us to ensure dist to be built before publishing the release and therefore will allow unpkg to deliver us a CDN endpoint.

* chore: added unpkg explicit file path

* chore: update package + fix API breaking for sinon

* build: remove build instruction from travis

* chore(package): build on prepublish

* feat: provide crypto.BLS

* chore: rebuild package-lock
  • Loading branch information
Alex-Werner authored Oct 5, 2020
1 parent d456762 commit d447fcc
Show file tree
Hide file tree
Showing 7 changed files with 2,154 additions and 2,236 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ npm install @dashevo/dashcore-lib

### Browser

See the section below to generate your own bundle, or download the pre-generated [minified file](dist/dashcore-lib.min.js)
#### CDN Standalone

```html
<script src="https://unpkg.com/@dashevo/dashcore-lib"></script>
<script>
const { PrivateKey } = dashcore;
const privateKey = new PrivateKey();
const address = privateKey.toAddress().toString();
...
</script>
```

#### Building the Browser Bundle

Expand All @@ -36,7 +46,7 @@ To build a dashcore-lib full bundle for the browser:
npm run build
```

This will generate files named `dashcore-lib.js` and `dashcore-lib.min.js` in the `dist/` folder.
This will generate a file named `dashcore-lib.min.js` in the `dist/` folder.

## Usage

Expand Down
18 changes: 18 additions & 0 deletions examples/web/usage.web.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- <script src="https://unpkg.com/@dashevo/dashcore-lib"></script>-->
<script src="../../dist/dashcore-lib.min.js"></script>
<script>
const { PrivateKey } = dashcore;
const privateKey = new PrivateKey();
const address = privateKey.toAddress().toString();
alert(`New private key generated ${privateKey.toString()}`);
</script>
</head>
<body>

</body>
</html>
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ global._dashcore = bitcore.version;
// crypto
bitcore.crypto = {};
bitcore.crypto.BN = require('./lib/crypto/bn');
bitcore.crypto.BLS = require('./lib/crypto/bls');
bitcore.crypto.ECDSA = require('./lib/crypto/ecdsa');
bitcore.crypto.Hash = require('./lib/crypto/hash');
bitcore.crypto.Random = require('./lib/crypto/random');
Expand Down
Loading

0 comments on commit d447fcc

Please sign in to comment.