Skip to content

Commit

Permalink
Build examples again
Browse files Browse the repository at this point in the history
This commit rebuilds all the examples. And adds a script that can build
them all.

usage:

```sh
node ./build-examples.js
```
  • Loading branch information
Einar Norðfjörð committed Oct 4, 2018
1 parent 6487d11 commit f0b4da9
Show file tree
Hide file tree
Showing 19 changed files with 15,750 additions and 1,530 deletions.
40 changes: 40 additions & 0 deletions build-examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const rollup = require('rollup');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');

const fs = require('fs');
const path = require('path');

async function build(example) {
console.log('Building ' + example);

const inputOptions = {
input: path.resolve(`./examples/${example}/script.js`),
plugins: [
resolve(),
commonjs()
]
}
const outputOptions = {
format: 'iife',
file: path.resolve(`./examples/${example}/build.js`),
name: example.replace(/-/g, ''),
}
// create a bundle
const bundle = await rollup.rollup(inputOptions);

// write bundle
await bundle.write(outputOptions);

console.log('Built ' + example);
}

const examples = fs.readdirSync('./examples');

Promise.all(examples.map(build))
.then(()=> console.log('Success!'))
.catch(err => {
console.error('Failed!');
console.error(err);
process.exit(1);
});
Loading

0 comments on commit f0b4da9

Please sign in to comment.