You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
779 B

  1. #!/usr/bin/env node
  2. "use strict";
  3. /* eslint-env node */
  4. let babelify = require("babelify");
  5. let browserify = require("browserify");
  6. let express = require("express");
  7. let glob = require("glob");
  8. let logger = require("morgan");
  9. let app = express();
  10. app.use(logger("dev"));
  11. app.use(express.static(__dirname));
  12. app.use("/benchmark", express.static(`${__dirname}/../benchmark`));
  13. app.use("/examples", express.static(`${__dirname}/../../examples`));
  14. app.get("/:dir/bundle.js", (req, res) => {
  15. browserify(glob.sync(
  16. `${__dirname}/../${req.params.dir}/**/*.js`
  17. ))
  18. .transform(babelify, {
  19. presets: "es2015",
  20. compact: false
  21. })
  22. .bundle()
  23. .pipe(res);
  24. });
  25. app.listen(8000, () => {
  26. console.log("Test server running at: http://localhost:8000/");
  27. });