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.

37 lines
869 B

  1. #!/usr/bin/env node
  2. /* eslint-env node */
  3. /* eslint no-console: 0 */
  4. /*
  5. * Small server whose main purpose is to ensure that both the specced code and
  6. * the specs get passed through Babel & Browserify before they are served to the
  7. * browser.
  8. */
  9. let express = require("express"),
  10. logger = require("morgan"),
  11. glob = require("glob"),
  12. browserify = require("browserify"),
  13. babelify = require("babelify");
  14. let app = express();
  15. app.use(logger("dev"));
  16. app.use(express.static(__dirname));
  17. app.get("/bundle.js", (req, res) => {
  18. let files = glob.sync(__dirname + "/**/*.js", {
  19. ignore: __dirname + "/vendor/**/*"
  20. });
  21. browserify(files)
  22. .transform(babelify, { presets: "es2015", compact: false })
  23. .bundle()
  24. .pipe(res);
  25. });
  26. app.listen(8000, () => {
  27. console.log("Spec server running at http://localhost:8000...");
  28. });