-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
70 lines (61 loc) · 1.85 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sass = require('gulp-ruby-sass'),
path = require('path'),
autoprefixer = require('gulp-autoprefixer'),
less = require('gulp-less'),
browserSync = require('browser-sync').create();
var DEST = 'build/';
gulp.task('scripts', function() {
return gulp.src([
'src/js/helpers/*.js',
'src/js/*.js',
])
.pipe(concat('custom.js'))
.pipe(gulp.dest(DEST+'/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(DEST+'/js'))
.pipe(browserSync.stream());
});
// TODO: Maybe we can simplify how sass compile the minify and unminify version
var compileSASS = function (filename, options) {
return sass('src/scss/*.scss', options)
.pipe(autoprefixer('last 2 versions', '> 5%'))
.pipe(concat(filename))
.pipe(gulp.dest(DEST+'/css'))
.pipe(browserSync.stream());
};
gulp.task('sass', function() {
return compileSASS('custom.css', {});
});
gulp.task('sass-minify', function() {
return compileSASS('custom.min.css', {style: 'compressed'});
});
gulp.task('less', function () {
return gulp.src('src/less/*.less')
.pipe(less())
.pipe(gulp.dest('www/css'))
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: './'
},
startPath: './www/home.html'
});
});
gulp.task('watch', function() {
// Watch .html files
gulp.watch('production/*.html', browserSync.reload);
// Watch .js files
gulp.watch('src/js/*.js', ['scripts']);
// Watch .scss files
//gulp.watch('src/scss/*.scss', ['sass', 'sass-minify']);
// Watch .less files
gulp.watch('src/less/*.less', ['less']);
});
// Default Task
gulp.task('default', ['browser-sync', 'watch']);