2017-10-02 04:49:42 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2017-10-25 20:19:42 +02:00
|
|
|
const babelify = require( "babelify" );
|
|
|
|
const browserify = require( "browserify" );
|
|
|
|
const express = require( "express" );
|
|
|
|
const glob = require( "glob" );
|
|
|
|
const logger = require( "morgan" );
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
app.use( logger( "dev" ) );
|
|
|
|
app.use( express.static( __dirname ) );
|
|
|
|
app.use( "/benchmark", express.static( `${ __dirname }/../benchmark` ) );
|
|
|
|
app.use( "/examples", express.static( `${ __dirname }/../../examples` ) );
|
|
|
|
|
|
|
|
app.get( "/:dir/bundle.js", ( req, res ) => {
|
|
|
|
|
|
|
|
browserify( glob.sync(
|
|
|
|
`${ __dirname }/../${ req.params.dir }/**/*.js`
|
|
|
|
) )
|
|
|
|
.transform( babelify, {
|
2017-12-31 23:01:29 +01:00
|
|
|
presets: "env",
|
2017-10-25 20:19:42 +02:00
|
|
|
compact: false
|
|
|
|
} )
|
|
|
|
.bundle()
|
|
|
|
.pipe( res );
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
app.listen( 8000, () => {
|
|
|
|
|
|
|
|
console.log( "Test server running at: http://localhost:8000/" );
|
|
|
|
|
|
|
|
} );
|