Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. /*
  2. ==========================================
  3. Redstamp JS Frontend Gulp Workflow
  4. Version: 0.1
  5. Written By: Curtis Campbell
  6. Last Edied By: Curtis Campbell
  7. ==========================================
  8. */
  9.  
  10. //Gulp Module Includes
  11. // ===================
  12.  
  13. var gulp = require('gulp'),
  14. util = require('gulp-util');
  15. jshint = require('gulp-jshint');
  16. stylish = require('jshint-stylish');
  17. compass = require('gulp-compass');
  18. concat = require('gulp-concat');
  19. uglify = require('gulp-uglify');
  20. minifyCSS = require('gulp-minify-css');
  21. plumber = require('gulp-plumber');
  22. rename = require('gulp-rename');
  23. autoprefixer = require('gulp-autoprefixer');
  24. browserSync = require('browser-sync').create();
  25.  
  26. // Configuration
  27. // =============
  28.  
  29. var config = {
  30. PROJECT_NAME : 'clever',
  31. sassSourceDir : 'source/sass/**/*.scss',
  32. jsSourceDir : 'source/js/**/*.js',
  33. cssDir : 'public/css',
  34. jsDir : 'public/js',
  35. imgDir : 'public/images',
  36. viewsDir : 'public/views',
  37. imgSourceDir : 'source/img',
  38. production: !!util.env.production
  39. }
  40.  
  41. // Display Successful Gulp Start Log
  42. // =================================
  43.  
  44. gulp.task('default', ['compass', 'js'], function() {
  45. return util.log('Gulp ran successfully.')
  46. });
  47.  
  48. // Compass Compile
  49. // ============
  50.  
  51. gulp.task('compass', function() {
  52. return gulp.src([config.sassSourceDir])
  53. .pipe(compass({
  54. css: config.cssDir,
  55. sass: 'source/sass'
  56. }))
  57. .pipe(gulp.dest(config.cssDir))
  58. .pipe(browserSync.stream());
  59. });
  60.  
  61. // Compile JavaScript
  62. // ==================
  63.  
  64. gulp.task('js', function() {
  65. return gulp.src(config.jsSourceDir)
  66. .pipe(plumber({
  67. errorHandler: function (error) {
  68. console.log(error.message);
  69. this.emit('end');
  70. }}))
  71. .pipe(jshint())
  72. .pipe(jshint.reporter('jshint-stylish'))
  73. .pipe(concat(config.PROJECT_NAME + '.min.js'))
  74. .pipe(uglify())
  75. .pipe(gulp.dest(config.jsDir))
  76. .pipe(browserSync.stream())
  77. });
  78.  
  79. // Browser Sync - Serve up assets to local server for page refresh etc
  80. // ===================================================================
  81.  
  82. gulp.task('browser-sync', function() {
  83. browserSync.init({
  84. server: {
  85. baseDir: './public'
  86. }
  87. });
  88.  
  89. gulp.watch(config.sassSourceDir, ['compass']);
  90. gulp.watch(config.jsSourceDir, ['js-watch']);
  91. gulp.watch('public/views/**/*.html').on('change', function() {
  92. browserSync.reload();
  93. });
  94. gulp.watch('public/index.html').on('change', function() {
  95. browserSync.reload();
  96. });
  97. });
  98.  
  99. // Watch Tasks
  100. // ===========
  101.  
  102. gulp.task('js-watch', ['js'], function() {
  103. browserSync.reload();
  104. });
  105.  
  106. gulp.task('sass-watch', ['compass'], function() {
  107. browserSync.reload();
  108. });
  109.  
  110. gulp.task('watch', ['browser-sync'], function() {
  111. return util.log('Watching for changes...');
  112. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement