gulpfile.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. require('es6-promise').polyfill();
  2. var gulp = require('gulp');
  3. var browserify = require('browserify');
  4. var concatCss = require('gulp-concat-css');
  5. var minifyCss = require('gulp-minify-css');
  6. var sass = require('gulp-sass');
  7. var uglify = require('gulp-uglify');
  8. var buffer = require('vinyl-buffer');
  9. var source = require('vinyl-source-stream');
  10. var sourcemaps = require('gulp-sourcemaps');
  11. var merge = require('merge-stream');
  12. var autoprefixer = require('gulp-autoprefixer');
  13. gulp.task('js', function() {
  14. browserify('./jet/static/jet/js/src/main.js')
  15. .bundle()
  16. .on('error', function(error) {
  17. console.error(error);
  18. })
  19. .pipe(source('bundle.min.js'))
  20. .pipe(buffer())
  21. .pipe(uglify({'mangle': false}))
  22. .pipe(gulp.dest('./jet/static/jet/js/build/'));
  23. });
  24. gulp.task('vendor-css', function() {
  25. merge(
  26. gulp.src([
  27. './node_modules/select2/dist/css/select2.css',
  28. './node_modules/jquery-ui/themes/base/all.css',
  29. './node_modules/timepicker/jquery.ui.timepicker.css'
  30. ]),
  31. gulp.src([
  32. './node_modules/perfect-scrollbar/src/css/main.scss'
  33. ])
  34. .pipe(sass())
  35. .on('error', function(error) {
  36. console.error(error);
  37. })
  38. )
  39. .pipe(minifyCss())
  40. .on('error', function(error) {
  41. console.error(error);
  42. })
  43. .pipe(concatCss('vendor.css'))
  44. .on('error', function(error) {
  45. console.error(error);
  46. })
  47. .pipe(gulp.dest('./jet/static/jet/css'));
  48. });
  49. gulp.task('scss', function() {
  50. gulp.src('./jet/static/jet/css/**/*.scss')
  51. .pipe(sourcemaps.init())
  52. .pipe(sass())
  53. .on('error', function(error) {
  54. console.error(error);
  55. })
  56. .pipe(autoprefixer())
  57. .on('error', function(error) {
  58. console.error(error);
  59. })
  60. .pipe(sourcemaps.write('./'))
  61. .pipe(gulp.dest('./jet/static/jet/css'));
  62. });
  63. gulp.task('watch', function() {
  64. gulp.watch('./jet/static/jet/js/src/**/*.js', ['js']);
  65. gulp.watch('./jet/static/jet/css/**/*.scss', ['scss']);
  66. });
  67. gulp.task('default', ['js', 'scss', 'vendor-css', 'watch']);