gulpfile.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var gulp = require('gulp');
  2. var autoprefixer = require('gulp-autoprefixer');
  3. const sass = require('gulp-sass')(require('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 order = require("gulp-order");
  12. function css(cb) {
  13. gulp.src('chat.scss')
  14. .pipe(sass.sync().on('error', gutil.log))
  15. .pipe(autoprefixer({
  16. cascade: false
  17. }))
  18. .pipe(gulp.dest('./'));
  19. cb();
  20. }
  21. function js(cb) {
  22. var templates = gulp.src('views/*.eco')
  23. .pipe(eco({namespace: 'zammadChatTemplates'}));
  24. var purify = gulp.src('purify.min.js');
  25. var js = gulp.src('chat.coffee')
  26. .pipe(coffee({bare: true}).on('error', gutil.log));
  27. merge(templates, purify, js)
  28. .pipe(order([
  29. "views/*.js",
  30. "purify.min.js",
  31. "chat.js",
  32. ], {base: './'}))
  33. .pipe(concat('chat.js'))
  34. .pipe(gulp.dest('./'))
  35. .pipe(uglify())
  36. .pipe(rename({ extname: '.min.js' }))
  37. .pipe(gulp.dest('./'));
  38. cb();
  39. }
  40. function no_jquery(cb) {
  41. var templates = gulp.src('views/*.eco')
  42. .pipe(eco({namespace: 'zammadChatTemplates'}));
  43. var purify = gulp.src('purify.min.js');
  44. var js = gulp.src('chat-no-jquery.coffee')
  45. .pipe(coffee({bare: true}).on('error', gutil.log));
  46. merge(templates, purify, js)
  47. .pipe(order([
  48. "views/*.js",
  49. "purify.min.js",
  50. "chat.js",
  51. ], {base: './'}))
  52. .pipe(concat('chat-no-jquery.js'))
  53. .pipe(gulp.dest('./'))
  54. .pipe(uglify())
  55. .pipe(rename({ extname: '.min.js' }))
  56. .pipe(gulp.dest('./'));
  57. cb();
  58. }
  59. exports.default = function() {
  60. gulp.watch(['chat.scss'], css);
  61. gulp.watch(['chat.coffee', 'views/*.eco'], js);
  62. gulp.watch(['chat-no-jquery.coffee', 'views/*.eco'], no_jquery);
  63. }
  64. exports.build = gulp.parallel(js, no_jquery, css)