gulpfile.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var gulp = require('gulp');
  2. var autoprefixer = require('gulp-autoprefixer');
  3. var sass = require('gulp-sass');
  4. var gutil = require('gulp-util');
  5. var concat = require('gulp-concat');
  6. var coffee = require('gulp-coffee');
  7. var eco = require('gulp-eco');
  8. var rename = require('gulp-rename');
  9. var uglify = require('gulp-uglify');
  10. var merge = require('merge-stream');
  11. var plumber = require('gulp-plumber');
  12. gulp.task('css', function(){
  13. return gulp.src('chat.scss')
  14. .pipe(sass.sync().on('error', gutil.log))
  15. .pipe(autoprefixer({
  16. browsers: ['last 4 versions'],
  17. cascade: false
  18. }))
  19. .pipe(gulp.dest('./'));
  20. });
  21. gulp.task('js', function(){
  22. var templates = gulp.src('views/*.eco')
  23. .pipe(eco({namespace: 'zammadChatTemplates'}));
  24. var js = gulp.src('chat.coffee')
  25. .pipe(plumber())
  26. .pipe(coffee({bare: true}).on('error', gutil.log));
  27. var autoGrow = gulp.src('jquery.autoGrow.js');
  28. return merge(templates, js, autoGrow)
  29. .pipe(concat('chat.js'))
  30. .pipe(gulp.dest('./'))
  31. .pipe(uglify())
  32. .pipe(rename({ extname: '.min.js' }))
  33. .pipe(gulp.dest('./'));
  34. });
  35. gulp.task('default', function(){
  36. var cssWatcher = gulp.watch('chat.scss', ['css']);
  37. cssWatcher.on('change', function(event) {
  38. console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
  39. });
  40. var jsWatcher = gulp.watch(['chat.coffee', 'views/*.eco'], ['js']);
  41. jsWatcher.on('change', function(event) {
  42. console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
  43. });
  44. });