xExekut3x

gulpfile

Nov 27th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. var gulp = require('gulp');
  2. var del = require('del');
  3. var concat = require('gulp-concat');
  4. var gulpFilter = require('gulp-filter');
  5. var postcss = require('gulp-postcss');
  6. var autoprefixer = require('autoprefixer');
  7. var mqpacker = require('css-mqpacker');
  8. var csswring = require('csswring');
  9. var cssnano = require('cssnano');
  10. var stylus = require('gulp-stylus');
  11. var uglify = require('gulp-uglify');
  12. var jscs = require('gulp-jscs');
  13. var jshint = require('gulp-jshint');
  14. //var noop = function() {};
  15. var stylish = require('gulp-jscs-stylish');
  16. //var browserSync = require('browser-sync').create();
  17. var browserSync = require('browser-sync');
  18. var nodemon = require('gulp-nodemon');
  19.  
  20. gulp.task('clean', function() {
  21. return del([
  22. 'public/**/*'
  23. ]);
  24. });
  25.  
  26. gulp.task('css', function() {
  27. var processors = [
  28. autoprefixer({browsers: ['last 1 version']}),
  29. mqpacker,
  30. csswring,
  31. cssnano
  32. ];
  33. var filter = gulpFilter(['*', '!normalize.min.css', '!flexboxgrid.min.css'], {restore: true});
  34. return gulp.src([
  35. './bower_components/normalize-css/normalize.min.css',
  36. './bower_components/flexboxgrid/dist/flexboxgrid.min.css',
  37. './src/css/**/*.styl'
  38. ])
  39. .pipe(filter)
  40. .pipe(stylus())
  41. .pipe(postcss(processors))
  42. .pipe(filter.restore)
  43. .pipe(concat('styles.css'))
  44. //.pipe(gulp.dest('./public/css'));
  45. .pipe(gulp.dest('./public/css'))
  46. .pipe(browserSync.stream());
  47. });
  48.  
  49. gulp.task('js', function() {
  50. var filter = gulpFilter(['*', '!masonry.pkgd.min.js'], {restore: true});
  51. return gulp.src([
  52. './bower_components/masonry/dist/masonry.pkgd.min.js',
  53. './src/js/**/*.js'
  54. ])
  55. .pipe(filter)
  56. .pipe(jshint())
  57. //.pipe(jscs())
  58. //.pipe(stylish.combineWithHintResults())
  59. .pipe(jshint.reporter('jshint-stylish'))
  60. .pipe(uglify())
  61. .pipe(filter.restore)
  62. .pipe(concat('scripts.js'))
  63. //.pipe(gulp.dest('./public/js'));
  64. .pipe(gulp.dest('./public/js'))
  65. .pipe(browserSync.stream());
  66. });
  67.  
  68. gulp.task('img', function() {
  69.  
  70. });
  71.  
  72. gulp.task('serve', ['nodemon', 'css', 'js'], function() {
  73. browserSync.init({
  74. port: 5000,
  75. proxy: 'http://localhost:3000',
  76. browser: ['google-chrome']
  77. });
  78. gulp.watch('./src/css/**/*.styl', ['css']);
  79. gulp.watch('./src/js/**/*.js', ['js']);
  80. });
  81.  
  82. gulp.task('nodemon', function(cb) {
  83. var called = false;
  84. return nodemon({
  85. watch: ['./app.js', './views**/*.jade']
  86. })
  87. .on('start', function onStart() {
  88. if (!called) {
  89. cb();
  90. }
  91. called = true;
  92. })
  93. .on('restart', function onRestart() {
  94. setTimeout(function reload() {
  95. browserSync.reload({
  96. stream: false
  97. }, 500);
  98. });
  99. })
  100. });
  101.  
  102. gulp.task('default', ['serve']);
Advertisement
Add Comment
Please, Sign In to add comment