Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. 'use strict';
  2. var concat = require('gulp-concat'),
  3. del = require('del'),
  4. uglify = require('gulp-uglify'),
  5. gulp = require('gulp'),
  6. browserSync = require('browser-sync'),
  7. nodemon = require('gulp-nodemon');
  8.  
  9. var BROWSER_SYNC_RELOAD_DELAY = 500;
  10. var paths = {
  11. js: [
  12. 'website/app/**/*.js',
  13. 'website/app/*.js'
  14. ],
  15. css: 'website/**/*.css',
  16. buildDestDel: 'website/_build/*',
  17. buildDest: 'website/_build',
  18. concatJsName: 'spawn.scripts.js'
  19. }
  20.  
  21. gulp.task('nodemon', function (cb) {
  22. var called = false;
  23. return nodemon({
  24. script: 'service/service.js',
  25. watch: ['service/**/*.js'],
  26. ext: 'js json'
  27. })
  28. .on('start', function onStart() {
  29. if (!called) { cb(); }
  30. called = true;
  31. })
  32. .on('restart', function onRestart() {
  33. setTimeout(function reload() {
  34. browserSync.reload({
  35. stream: false
  36. });
  37. }, BROWSER_SYNC_RELOAD_DELAY);
  38. });
  39. });
  40.  
  41. gulp.task('browser-sync', ['nodemon'], function () {
  42. browserSync({
  43. server: {
  44. baseDir: 'website'
  45. },
  46. notify: true,
  47. open: false
  48. });
  49. });
  50.  
  51. gulp.task('clean:js', function() {
  52. return del(paths.buildDestDel);
  53. });
  54.  
  55. gulp.task('js', ['clean:js'], function () {
  56. return gulp.src(paths.js)
  57. .pipe(concat(paths.concatJsName))
  58. .pipe(gulp.dest(paths.buildDest));
  59. });
  60.  
  61. gulp.task('css', function () {
  62. return gulp.src(paths.css)
  63. .pipe(browserSync.reload({ stream: true }));
  64. });
  65.  
  66. gulp.task('bs-reload', function () {
  67. browserSync.reload();
  68. });
  69.  
  70. gulp.task('default', ['browser-sync', 'js'], function () {
  71. gulp.watch('website/**/*.js', ['js', 'bs-reload']);
  72. gulp.watch('website/**/*.css', ['css']);
  73. gulp.watch('website/**/*.html', ['bs-reload']);
  74. gulp.watch('website/templates/**/*.html', ['bs-reload']);
  75. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement