-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (46 loc) · 1.48 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
prefix = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
mainBowerFiles = require('main-bower-files'),
bs = require('browser-sync').create();
gulp.task('static', function(){
return gulp.src('./*.html')
.pipe(gulp.dest('dist'));
});
gulp.task('scripts', function(){
return gulp.src([
'./js/**/*.js'
])
.pipe(jshint())
.pipe(gulp.dest('dist/js'));
});
gulp.task('styles', function(){
return gulp.src('sass/**/*.scss')
.pipe(sass({
includePaths: [ 'bower_components']
}).on('error', sass.logError))
.pipe(prefix())
.pipe(gulp.dest('dist/css'));
});
// Task for serving blog with Browsersync
gulp.task('serve', function () {
bs.init({server: {baseDir: 'dist'}, port: 4000});
// Reloads page when some of the already built files changed:
gulp.watch('dist/**/*').on('change', bs.reload);
});
gulp.task('dependencies', function(){
var glob = mainBowerFiles('**/*.js');
return gulp.src(glob)
.pipe(concat('deps.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
gulp.task('watch',function(){
gulp.watch('./*.html', ['static']);
gulp.watch('./js/**/*.js', ['scripts']);
gulp.watch('./sass/**/*.scss', ['styles']);
});
gulp.task('default', ['dependencies','styles','watch','scripts','serve']);