-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
19 changed files
with
15,750 additions
and
1,530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.