From d4bcddacd85d280b8a39cedb0b5c0a48aa8c7a33 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 21 Jun 2017 17:39:19 +0200 Subject: [PATCH] Add all browser bundles --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++-- webpack.config.js | 51 ++++++++++++++++++++++++++++------- 2 files changed, 108 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3e57c68..d797f83 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,15 @@ * [Authors](#authors) * [License](#license) -## Installation +## Node.js + +### Installation ```bash npm install bigchaindb-driver ``` -### Example: Create a transaction +#### Example: Create a transaction ```js import * as driver from 'bigchaindb-driver' @@ -73,6 +75,69 @@ conn.postTransaction(txSigned) .then((res) => console.log('Transaction status:', res.status)) ``` +## Browser + +### Installation and Usage + +```html + + + + + HTML5 boilerplate – all you really need… + + + + + + + +

Hello BigchainDB

+ + + +``` + ## BigchainDB Documentation - [HTTP API Reference](https://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html) diff --git a/webpack.config.js b/webpack.config.js index 211f43e..13e0def 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,6 +14,39 @@ const PATHS = { NODE_MODULES: path.resolve(__dirname, 'node_modules'), } +const OUTPUTS = [ + { + filename: PRODUCTION ? 'bundle.window.min.js' : 'bundle.window.js', + library: 'BigchainDB', + libraryTarget: 'window', + path: PATHS.BUNDLE, + }, + { + filename: PRODUCTION ? 'bundle.umd.min.js' : 'bundle.umd.js', + library: 'bigchaindb-driver', + libraryTarget: 'umd', + path: PATHS.BUNDLE, + }, + { + filename: PRODUCTION ? 'bundle.cjs.min.js' : 'bundle.cjs.js', + library: 'bigchaindb-driver', + libraryTarget: 'commonjs', + path: PATHS.BUNDLE, + }, + { + filename: PRODUCTION ? 'bundle.cjs2.min.js' : 'bundle.cjs2.js', + library: 'bigchaindb-driver', + libraryTarget: 'commonjs2', + path: PATHS.BUNDLE, + }, + { + filename: PRODUCTION ? 'bundle.amd.min.js' : 'bundle.amd.js', + library: 'bigchaindb-driver', + libraryTarget: 'amd', + path: PATHS.BUNDLE, + } +] + /** PLUGINS **/ const PLUGINS = [ @@ -40,18 +73,9 @@ if (PRODUCTION) { PLUGINS.push(...PROD_PLUGINS) } - -/** EXPORTED WEBPACK CONFIG **/ -const config = { +const configBoilerplate = { entry: [PATHS.ENTRY], - output: { - filename: PRODUCTION ? 'bundle.min.js' : 'bundle.js', - library: 'js-bigchaindb-driver', - libraryTarget: 'umd', - path: PATHS.BUNDLE, - }, - devtool: PRODUCTION ? '#source-map' : '#inline-source-map', resolve: { @@ -77,4 +101,11 @@ const config = { }, } +/** EXPORTED WEBPACK CONFIG **/ +const config = OUTPUTS.map(output => { + const configCopy = Object.assign({}, configBoilerplate) + configCopy.output = output + return configCopy +}) + module.exports = config