Gulpfile.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. var gulp = require('gulp'),
  2. bower = require('gulp-bower')
  3. sass = require('gulp-ruby-sass'),
  4. minifycss = require('gulp-minify-css'),
  5. uglify = require('gulp-uglify'),
  6. rename = require('gulp-rename'),
  7. concat = require('gulp-concat'),
  8. notify = require('gulp-notify');
  9. var config = {
  10. 
 sassPath: './src',
  11. sassDestPath: './static/css',
  12. jsPath: './static/js',
  13. 
 bowerDir: './bower_components'

  14. }
  15. // install dependencies
  16. gulp.task('bower', function() {

  17. return bower()
  18. 
 .pipe(gulp.dest(config.bowerDir))

  19. });
  20. // update dependencies
  21. gulp.task('update', function() {
  22. return bower({ cmd: 'update'});
  23. });
  24. gulp.task('icons', function() {

  25. return gulp.src(config.bowerDir + '/font-awesome/fonts/**.*')

  26. .pipe(gulp.dest('./static/fonts'));

  27. });
  28. gulp.task('sass', function () {
  29. return sass(config.sassPath + '/styles.scss', {
  30. style: 'compressed',
  31. loadPath: [
  32. './src/',
  33. 
 config.bowerDir + '/bootstrap-sass/assets/stylesheets',
  34. 
 config.bowerDir + '/font-awesome/scss'
  35. ]
  36. })
  37. .on("error", notify.onError(function (error) {
  38. 
 return "Error: " + error.message;
  39. 
 }))
  40. // add the bootstrap-markdown style to the styles.css
  41. .pipe(gulp.dest(config.sassDestPath));
  42. });
  43. gulp.task('css', ['sass'], function() {
  44. return gulp.src([
  45. config.sassDestPath + '/styles.css',
  46. config.bowerDir + '/bootstrap-markdown/css/bootstrap-markdown.min.css'])
  47. .pipe(concat('styles.css'))
  48. .pipe(gulp.dest(config.sassDestPath));
  49. })
  50. gulp.task('main-scripts', function() {
  51. return gulp.src([config.bowerDir + '/jquery/dist/jquery.min.js',
  52. config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.min.js',
  53. config.jsPath + '/flaskbb.js'])
  54. .pipe(concat('scripts.min.js'))
  55. .pipe(uglify())
  56. .pipe(gulp.dest(config.jsPath));
  57. });
  58. // all the scripts that are needed for our texteditor
  59. // we bundle them extra because we do not always need them
  60. gulp.task('editor-scripts', function() {
  61. return gulp.src([
  62. config.bowerDir + '/marked/lib/marked.js',
  63. config.bowerDir + '/bootstrap-markdown/js/bootstrap-markdown.js',
  64. config.bowerDir + '/jquery-textcomplete/dist/jquery.textcomplete.min.js',
  65. config.jsPath + '/emoji.js',
  66. config.jsPath + '/editor.js'])
  67. .pipe(concat('editor.min.js'))
  68. .pipe(uglify())
  69. .pipe(gulp.dest(config.jsPath));
  70. })
  71. gulp.task('scripts', ['main-scripts', 'editor-scripts'], function() {});
  72. // Rerun the task when a file changes
  73. 
gulp.task('watch', function() {
  74. 
 gulp.watch(config.sassPath + '/*.scss', ['css']);

  75. gulp.watch(config.jsPath + '/*.js', ['scripts'])
  76. });
  77. 

gulp.task('default', ['bower', 'icons', 'css', 'scripts']);