Advertisement
connorblikre

gulpfilejs

Aug 20th, 2015
539
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var gulp = require('gulp');
  2. var less = require('gulp-less-sourcemap');
  3. var uglify = require('gulp-uglify');
  4. var concat = require('gulp-concat');
  5. var imagemin = require('gulp-imagemin');
  6. var path = require('path');
  7.  
  8. var themeMainDir = './wp-content/themes/ThemeName';
  9. var cssMainDir = themeMainDir + '/css';
  10. var lessMainDir = cssMainDir + '/less';
  11. var jsMainDir = themeMainDir + '/js';
  12. var imageMainDir = themeMainDir + '/images';
  13.  
  14. gulp.task('less', function () {
  15.   return gulp.src([lessMainDir + '/style.less', lessMainDir + '/editor-style.less'])
  16.     .pipe(less({
  17.       paths: [ path.join(__dirname, 'less', 'includes') ],
  18.       compress: true,
  19.       sourceMap: { sourceMapRootpath: lessMainDir }
  20.     }).on('error', function(error){
  21.       console.log(error.message);
  22.     }))
  23.     .pipe(gulp.dest(cssMainDir));
  24. });
  25.  
  26. gulp.task('concat', function(){
  27.     return gulp.src([jsMainDir + '/lightbox.js', jsMainDir + '/plugins.js', jsMainDir + '/main.js'])
  28.   .pipe(concat('main.min.js'))
  29.     .pipe(uglify())
  30.     .pipe(gulp.dest(jsMainDir));
  31. });
  32.  
  33. gulp.task('image-compress', function () {
  34.   return gulp.src(imageMainDir + '/**/*')
  35.     .pipe(imagemin())
  36.     .pipe(gulp.dest(imageMainDir));
  37. });
  38.  
  39. gulp.task('uploads-compress', function () {
  40.   return gulp.src('./wp-content/uploads/**/*')
  41.     .pipe(imagemin())
  42.     .pipe(gulp.dest('./wp-content/uploads'));
  43. });
  44.  
  45. gulp.task('watch', function() {
  46.   gulp.watch(lessMainDir + '/**/*.less', ['less']);
  47.   gulp.watch([jsMainDir + '/main.js', jsMainDir + '/plugins.js'], ['concat']);
  48. });
Advertisement
RAW Paste Data Copied
Advertisement