2016-05-24 16:53:42 +00:00
|
|
|
var gulp = require('gulp'),
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
uglify = require('gulp-uglify'),
|
|
|
|
rename = require('gulp-rename'),
|
2016-05-28 17:20:52 +00:00
|
|
|
sass = require('gulp-ruby-sass'),
|
|
|
|
autoprefixer = require('gulp-autoprefixer'),
|
|
|
|
browserSync = require('browser-sync').create();
|
2016-05-24 16:53:42 +00:00
|
|
|
|
|
|
|
var DEST = 'build/';
|
|
|
|
|
|
|
|
gulp.task('scripts', function() {
|
2016-07-06 16:35:21 +00:00
|
|
|
return gulp.src([
|
|
|
|
'src/js/helpers/*.js',
|
|
|
|
'src/js/*.js',
|
|
|
|
])
|
2016-05-24 16:53:42 +00:00
|
|
|
.pipe(concat('custom.js'))
|
|
|
|
.pipe(gulp.dest(DEST+'/js'))
|
|
|
|
.pipe(rename({suffix: '.min'}))
|
|
|
|
.pipe(uglify())
|
2016-05-28 17:20:52 +00:00
|
|
|
.pipe(gulp.dest(DEST+'/js'))
|
|
|
|
.pipe(browserSync.stream());
|
2016-05-24 16:53:42 +00:00
|
|
|
});
|
|
|
|
|
2016-05-24 17:19:59 +00:00
|
|
|
// TODO: Maybe we can simplify how sass compile the minify and unminify version
|
|
|
|
var compileSASS = function (filename, options) {
|
|
|
|
return sass('src/scss/*.scss', options)
|
2016-05-28 17:20:52 +00:00
|
|
|
.pipe(autoprefixer('last 2 versions', '> 5%'))
|
2016-05-24 17:19:59 +00:00
|
|
|
.pipe(concat(filename))
|
2016-05-28 17:20:52 +00:00
|
|
|
.pipe(gulp.dest(DEST+'/css'))
|
|
|
|
.pipe(browserSync.stream());
|
2016-05-24 17:19:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gulp.task('sass', function() {
|
|
|
|
return compileSASS('custom.css', {});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('sass-minify', function() {
|
|
|
|
return compileSASS('custom.min.css', {style: 'compressed'});
|
2016-05-24 16:53:42 +00:00
|
|
|
});
|
|
|
|
|
2016-05-28 17:20:52 +00:00
|
|
|
gulp.task('browser-sync', function() {
|
|
|
|
browserSync.init({
|
|
|
|
server: {
|
|
|
|
baseDir: './'
|
|
|
|
},
|
|
|
|
startPath: './production/index.html'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-05-24 16:53:42 +00:00
|
|
|
gulp.task('watch', function() {
|
2016-05-28 17:20:52 +00:00
|
|
|
// Watch .html files
|
|
|
|
gulp.watch('production/*.html', browserSync.reload);
|
|
|
|
// Watch .js files
|
2016-05-24 16:53:42 +00:00
|
|
|
gulp.watch('src/js/*.js', ['scripts']);
|
2016-05-28 17:20:52 +00:00
|
|
|
// Watch .scss files
|
2016-05-24 17:19:59 +00:00
|
|
|
gulp.watch('src/scss/*.scss', ['sass', 'sass-minify']);
|
2016-05-24 16:53:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Default Task
|
2016-05-28 17:20:52 +00:00
|
|
|
gulp.task('default', ['browser-sync', 'watch']);
|