-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
103 lines (93 loc) · 2.8 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
sassGlob = require('gulp-sass-glob'),
livereload = require('gulp-livereload'),
imagemin = require('gulp-imagemin'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
harp = require('harp');
gulp.task('build-js', function() {
return gulp.src('build/js/**/*.js')
// .pipe(uglify({
// console: true
// }))
// .pipe(concat('main.js'))
.pipe(gulp.dest('public/js/'))
.pipe(browserSync.stream());
});
gulp.task('build-scss', function() {
return gulp.src('build/sass/**/*.scss')
.pipe(sassGlob())
//.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
//.pipe(sourcemaps.write())
.pipe(gulp.dest('public/stylesheets'))
.pipe(browserSync.stream());
});
gulp.task('build-html', function() {
return gulp.src('craft/templates/**/*.*')
.pipe(browserSync.reload);
});
gulp.task('build-images', function(){
return gulp.src('build/img/*.*')
.pipe(imagemin())
.pipe(gulp.dest('public/img'))
.pipe(browserSync.reload);
});
gulp.task('jshint', function() {
return gulp.src('build/js/**/*.js')
.pipe(jshint({
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
"globals": {
"$": true
}
}))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('serve', function () {
harp.server(__dirname, {
port: 9000
}, function () {
browserSync({
proxy: "localhost:9000",
open: false,
/* Hide the notification. It gets annoying */
notify: {
styles: ['opacity: 0', 'position: absolute']
}
});
/**
* Watch for scss changes, tell BrowserSync to refresh main.css
*/
gulp.watch(["*.css", "*.sass", "*.scss", "*.less"], function () {
reload("main.css", {stream: true});
});
/**
* Watch for all other changes, reload the whole page
*/
gulp.watch(["*.html", "**/*.ejs", "*.jade", "*.js", "*.json", "*.md"], function () {
reload();
});
})
});
/**
* Default task, running `gulp` will fire up the Harp site,
* launch BrowserSync & watch files.
*/
gulp.task('default', ['serve']);
gulp.task('watch', function() {
gulp.start('serve');
gulp.watch('build/js/**/*.js', ['jshint','build-js']);
gulp.watch('build/sass/**/*.scss', ['build-scss']);
gulp.watch('build/img/*.*', ['build-images']);
gulp.watch('public/**/*.ejs', ['build-html','build-images']);
});