Skip to content
Permalink
Browse files

Add task to build browser scripts (#4)

* feat(build): add task to build browser scripts

* fix(build): create another entry script for browser

* build: rebuild browser scripts

* feat(browserify): add browser entry point in package.json
  • Loading branch information...
thammin authored and suguru03 committed Feb 16, 2017
1 parent 6cf1399 commit 8a88f908f71581ec06089f509f52926aac738525
Showing with 9,239 additions and 2 deletions.
  1. +25 βˆ’0 README.md
  2. +4 βˆ’0 browser.js
  3. +21 βˆ’0 build.js
  4. +4,905 βˆ’0 dist/aigle-es5.js
  5. +3 βˆ’0 dist/aigle-es5.min.js
  6. +4,270 βˆ’0 dist/aigle.js
  7. +2 βˆ’0 dist/aigle.min.js
  8. +9 βˆ’2 package.json
@@ -10,3 +10,28 @@ All Aigle class is extended by same [Aigle-Core](https://github.com/suguru03/aig
Also Aigle has a lot of [async](https://github.com/caolan/async) functions, you can start to use `Promise` easily.

Let's stop using Async, let's start to use Aigle.

Usage
--

#### node
```sh
npm install --save aigle
```

```js
const Promise = require('aigle');
```

#### browser
Recommend to use [webpack](https://github.com/webpack/webpack), [browserify](https://github.com/substack/node-browserify), [Rollup](https://github.com/rollup/rollup) or any bundling tool.

##### or prebuilt scripts from [here](https://github.com/suguru03/aigle/tree/master/dist/).
This will expose to global as `window.Promise`.
```html
<script src="dist/aigle.min.js"></script>
```

```js
window.Promise;
```
@@ -0,0 +1,4 @@
'use strict';

require('setimmediate');
module.exports = require('./lib/aigle');
@@ -0,0 +1,21 @@
const fs = require('fs');
const { exec } = require('child_process');

const builds = [
['browserify', './browser.js -s Promise', './dist/aigle.js' ],
['babili', './dist/aigle.js', './dist/aigle.min.js' ],
['buble', './dist/aigle.js', './dist/aigle-es5.js' ],
['uglifyjs', '--compress --mangle -- ./dist/aigle-es5.js', './dist/aigle-es5.min.js']
];

builds.reduce((promise, [command, args, output]) => {
return promise.then(() => new Promise(resolve => {
exec(`./node_modules/.bin/${command} ${args}`)
.stdout
.on('end', () => {
console.log(`built: \x1b[32m${output}\x1b[0m`);
resolve();
})
.pipe(fs.createWriteStream(output));
}));
}, Promise.resolve());

0 comments on commit 8a88f90

Please sign in to comment.
You can’t perform that action at this time.