Created
March 29, 2016 06:41
-
-
Save chyngyz/ea828b9ae10dc084656b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var notify = require("gulp-notify"); | |
var Path = { | |
rootDir: 'staticfiles/dev', | |
rootDist: 'staticfiles/dist', | |
staticJs: 'staticfiles/dev/js', | |
staticCSS: 'staticfiles/dev/styles', | |
staticImg: 'staticfiles/dev/img', | |
staticFonts: 'staticfiles/dev/fonts' | |
} | |
// Load plugins | |
var $ = require('gulp-load-plugins')(); | |
// Styles | |
gulp.task('styles', function () { | |
return gulp.src(Path.staticCSS + '/main.scss') | |
.pipe($.sass().on('error', $.sass.logError)) | |
//.pipe($.autoprefixer('last 1 version')) | |
.pipe($.csso()) | |
.pipe(gulp.dest(Path.rootDist + '/styles')) | |
.pipe($.size()); | |
}); | |
// Scripts | |
gulp.task('scripts', function () { | |
return gulp.src(Path.staticJs + '/**/*.js') | |
.pipe($.jshint('.jshintrc')) | |
.pipe($.jshint.reporter('default')) | |
.pipe($.uglify()) | |
// .pipe($.gzip()) | |
.pipe(gulp.dest(Path.rootDist + '/js')) | |
.pipe($.size()); | |
}); | |
// Images | |
gulp.task('images', function () { | |
return gulp.src(Path.staticImg + '/**/*') | |
.pipe($.imagemin({ | |
optimizationLevel: 3, | |
progressive: true, | |
interlaced: true | |
})) | |
.pipe(gulp.dest(Path.rootDist + '/img')) | |
.pipe($.size()); | |
}); | |
// Fonts | |
gulp.task('fonts', function() { | |
return gulp.src(Path.staticFonts +'/**/*') | |
.pipe(gulp.dest(Path.rootDist + '/fonts')); | |
}); | |
// Clean | |
gulp.task('clean', function () { | |
return gulp.src(Path.rootDist, { read: false }).pipe($.rimraf()); | |
}); | |
// Build | |
gulp.task('build', ['styles','scripts', 'images', 'fonts']); | |
// Default task | |
gulp.task('default', ['clean'], function () { | |
gulp.start('build'); | |
}); | |
// Watch | |
gulp.task('serve', ['default'], function () { | |
// Watch .css files | |
gulp.watch(Path.staticCSS + '/*.scss', ['styles']); | |
// Watch .js files | |
gulp.watch(Path.staticJs + '/**/*.js', ['scripts']); | |
// Watch image files | |
gulp.watch(Path.staticImg + '/**/*', ['images']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment