Advertisement
nazares

gulpfile

Nov 18th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var gulp = require('gulp'),
  2.   sass = require('gulp-sass'),
  3.   jade = require('gulp-jade-php'),
  4.   concat = require('gulp-concat'),
  5.   notify = require('gulp-notify'),
  6.   cssmin = require('gulp-cssmin'),
  7.   rename = require('gulp-rename'),
  8.   uglify = require('gulp-uglify'),
  9.   autoprefixer = require('gulp-autoprefixer');
  10.    
  11. var path = {
  12.   src: {
  13.     styles: 'git/**/*.scss',
  14.     scripts: 'git/**/scripts/*.js',
  15.     jade: 'git/**/*.jade'
  16.   },
  17.   publicPath: "../",
  18.   npm: {
  19.     jquery: 'bower_components/jquery/dist/jquery.min.js',
  20.     bootstrap: 'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
  21.         swiper: 'bower_components/swiper/dist/js/swiper.jquery.min.js'
  22.   },
  23.   watch: {
  24.     styles: 'git/**/*.scss',
  25.     scripts: 'git/**/*.js',
  26.     jade: 'git/**/*.jade'
  27.   }
  28. };
  29.  
  30. var scriptPaths = [path.src.scripts, path.npm.jquery, path.npm.bootstrap, path.npm.swiper];
  31.  
  32. // Styles //
  33. gulp.task('styles', function () {
  34.   return gulp.src(path.src.styles)
  35.   .pipe(sass())
  36.   .pipe(autoprefixer({
  37.     browsers: ['last 50 versions']
  38.   }))
  39.   .pipe(notify({
  40.     message: 'Sass Success'
  41.   }))
  42.   .pipe(gulp.dest(path.publicPath))
  43. });
  44.  
  45. gulp.task('build:styles', function () {
  46.   return gulp.src(path.src.styles)
  47.   .pipe(sass())
  48.   .pipe(autoprefixer({
  49.     browsers: ['last 50 versions']
  50.   }))
  51.   .pipe(cssmin())
  52.   .pipe(rename({
  53.     suffix: '.min'
  54.   }))
  55.   .pipe(notify({
  56.     message: 'Sass Success'
  57.   }))
  58.   .pipe(gulp.dest(path.publicPath))
  59. });
  60.  
  61. // HTML //
  62. gulp.task('html', function () {
  63.   return gulp.src(path.src.jade)
  64.   .pipe(jade({
  65.     pretty: true
  66.   }))
  67.   .pipe(notify({
  68.     message: 'Jade Success'
  69.   }))
  70.   .pipe(gulp.dest(path.publicPath))
  71. });
  72.  
  73. // Scripts //
  74. gulp.task('scripts', function () {
  75.     return gulp.src(scriptPaths)
  76.   .pipe(concat('script.js'))
  77.   .pipe(notify({
  78.     message: 'Javascript Success'
  79.   }))
  80.     .pipe(gulp.dest(path.publicPath))
  81. });
  82.  
  83. gulp.task('build:scripts', function () {
  84.     return gulp.src(scriptPaths)
  85.   .pipe(concat('script.js'))
  86.   .pipe(uglify())
  87.   .pipe(rename({
  88.     suffix: '.min'
  89.   }))
  90.   .pipe(notify({
  91.     message: 'Javascript Success'
  92.   }))
  93.     .pipe(gulp.dest(path.publicPath))
  94. });
  95.  
  96. // Watch //
  97. gulp.task('watch', function () {
  98.   gulp.watch(path.watch.styles, ['styles']);
  99.   gulp.watch(path.watch.scripts, ['scripts']);
  100.   gulp.watch(path.watch.jade, ['html']);
  101. });
  102.  
  103. gulp.task('default', ['styles', 'scripts', 'html']);
  104. gulp.task('build', ['build:styles', 'build:scripts', 'html']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement