gulpfile.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. var gulp = require('gulp');
  3. var sass = require('gulp-sass');
  4. var rename = require('gulp-rename');
  5. var shell = require('gulp-shell')
  6. var watch = require('gulp-watch');
  7. var webserver = require('gulp-webserver');
  8. var portscanner = require('portscanner');
  9. gulp.task('webserver', ['build'], function() {
  10. // Find the first available port. Asynchronously checks, so first port
  11. // determined as available is returned.
  12. portscanner.findAPortNotInUse(8000, 8020, '127.0.0.1', function(error, port) {
  13. // console.log('AVAILABLE PORT AT: ' + port)
  14. gulp.src('.')
  15. .pipe(webserver({
  16. port:port,
  17. livereload: false,
  18. directoryListing: false,
  19. open: false,
  20. fallback: 'index.html'
  21. }));
  22. })
  23. });
  24. gulp.task('scss', function () {
  25. gulp.src('./assets/css/main.scss')
  26. .pipe(sass().on('error', sass.logError))
  27. .pipe(gulp.dest('./assets/css/dist'));
  28. });
  29. gulp.task('gui', function () {
  30. gulp.src('./assets/css/gui.scss')
  31. .pipe(sass().on('error', sass.logError))
  32. .pipe(gulp.dest('./assets/css/dist'));
  33. });
  34. // gulp.task('sync', shell.task([
  35. // './bin/sync.sh'
  36. // ]));
  37. gulp.task('build', shell.task([
  38. './bin/build.py'
  39. ]));
  40. // default gulp task
  41. gulp.task('default', ['scss', 'gui', 'webserver'], function() {
  42. gulp.watch('./assets/css/**/*.scss', ['scss']);
  43. gulp.watch('./assets/css/gui.scss', ['gui']);
  44. gulp.watch(['bin/build.py', './book-src/*', './templates/*.tpl.html'], ['build']);
  45. });