gulpfile.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*global require:true, console:true */
  2. var gulp = require('gulp');
  3. var nodemon = require('gulp-nodemon');
  4. var jshint = require('gulp-jshint');
  5. var uglify = require('gulp-uglify');
  6. var minifyHTML = require('gulp-minify-html');
  7. var minifycss = require('gulp-minify-css');
  8. var concat = require('gulp-concat');
  9. var del = require('del');
  10. var hintTask = function () {
  11. gulp.src(['*.js', './src/js/**/*.js'])
  12. .pipe(jshint('.jshintrc'))
  13. .pipe(jshint.reporter('jshint-stylish'));
  14. console.log('HINT: Hint Complete');
  15. };
  16. gulp.task('hint', function() {
  17. hintTask();
  18. });
  19. var cleanTask = function () {
  20. console.log('CLEAN: Clean Complete');
  21. return del([
  22. 'app/**/*',
  23. '!app/img/',
  24. '!app/css/',
  25. '!app/fonts/',
  26. '!app/js/',
  27. ]);
  28. };
  29. gulp.task('clean', function() {
  30. cleanTask();
  31. });
  32. var buildTask = function() {
  33. gulp.src('./src/app.js')
  34. .pipe(gulp.dest('./app'));
  35. gulp.src('./src/index.html')
  36. .pipe(minifyHTML())
  37. .pipe(gulp.dest('./app'));
  38. gulp.src('./src/img/*')
  39. .pipe(gulp.dest('./app/img'));
  40. gulp.src('./src/fonts/*')
  41. .pipe(gulp.dest('./app/fonts'));
  42. gulp.src(['./src/css/bootstrap-v3.3.6.css', './src/css/main.css'])
  43. .pipe(concat('style.min.css'))
  44. .pipe(minifycss())
  45. .pipe(gulp.dest('./app/css'));
  46. gulp.src([
  47. './src/js/jquery-v2.1.4.js',
  48. './src/js/bootstrap-v3.3.6.js',
  49. './src/js/bootstrap-validator-v0.9.0.js',
  50. './src/js/bootstrap-progress-v0.9.0.js',
  51. './src/js/underscore-v1.8.3.js',
  52. './src/js/handlebars-v4.0.5.js'
  53. ])
  54. .pipe(concat('vendor.min.js'))
  55. .pipe(uglify())
  56. .pipe(gulp.dest('./app/js'));
  57. gulp.src(['./src/js/webrtc-adapter.js', './src/js/webrtc-audio.js', './src/js/webrtc-video.js'])
  58. .pipe(concat('webrtc.min.js'))
  59. .pipe(uglify())
  60. .pipe(gulp.dest('./app/js'));
  61. gulp.src('./src/js/templates/*')
  62. .pipe(gulp.dest('./app/js/templates'));
  63. gulp.src(['./src/js/chat.js', './src/js/amplitude-v2.2.0.js', './src/js/radio.js'])
  64. .pipe(concat('radio.min.js'))
  65. .pipe(uglify())
  66. .pipe(gulp.dest('./app/js'));
  67. console.log('BUILD: Build Complete');
  68. };
  69. gulp.task('build', function() {
  70. buildTask();
  71. });
  72. var watchTask = function() {
  73. gulp.src('./src/app.js')
  74. .pipe(gulp.dest('./app'));
  75. gulp.src('./src/index.html')
  76. .pipe(minifyHTML())
  77. .pipe(gulp.dest('./app'));
  78. gulp.src(['./src/css/bootstrap-v3.3.6.css', './src/css/main.css'])
  79. .pipe(concat('style.min.css'))
  80. .pipe(minifycss())
  81. .pipe(gulp.dest('./app/css'));
  82. gulp.src('./src/js/templates/*')
  83. .pipe(gulp.dest('./app/js/templates'));
  84. gulp.src(['./src/js/amplitude-v2.2.0.js', './src/js/chat.js', './src/js/radio.js'])
  85. .pipe(concat('radio.min.js'))
  86. .pipe(uglify())
  87. .pipe(gulp.dest('./app/js'));
  88. console.log('WATCH: Watch Complete');
  89. };
  90. gulp.task('watch', function() {
  91. watchTask();
  92. });
  93. var nodemonTask = function() {
  94. nodemon({
  95. tasks: ['watch'],
  96. script: 'app.js',
  97. verbose: true,
  98. env: { 'NODE_ENV': 'development' },
  99. watch: ['./src/'],
  100. ext: 'css js html'
  101. });
  102. };
  103. gulp.task('run', function () {
  104. nodemonTask();
  105. });