-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·78 lines (63 loc) · 1.76 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
coffee = require('gulp-coffee'),
browserify = require('gulp-browserify'),
compass = require('gulp-compass'),
connect = require('gulp-connect'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
minifyHTML = require('gulp-minify-html'),
jsonminify = require('gulp-jsonminify'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
plumber = require('gulp-plumber');
var env,
jsSources,
sassSources,
htmlSources,
outputDir,
sassStyle;
env = process.env.NODE_ENV || 'development';
if (env==='development') {
outputDir = './public/';
sassStyle = 'expanded';
} else {
outputDir = 'builds/production/';
sassStyle = 'compressed';
}
jsSources = ['development/js/*.js'];
sassSources = ['development/sass/*.scss'];
htmlSources = ['*.html'];
gulp.task('js', function() {
gulp.src(jsSources)
.pipe(concat('script.js'))
.pipe(browserify())
.pipe(gulpif(env === 'production', uglify()))
.pipe(gulp.dest(outputDir + 'js'))
.pipe(connect.reload())
});
gulp.task('sass', function () {
gulp.src(sassSources)
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest(outputDir+'/css/'))
.pipe(connect.reload())
});
gulp.task('watch', function() {
gulp.watch(sassSources, ['sass']);
gulp.watch(jsSources, ['js']);
gulp.watch('./*.html', ['html']);
});
gulp.task('connect', function() {
connect.server({
root: "./",
livereload: true
});
});
gulp.task('html', function() {
gulp.src('./*.html')
.pipe(gulpif(env === 'production', minifyHTML()))
.pipe(gulpif(env === 'production', gulp.dest(outputDir)))
.pipe(connect.reload())
});
gulp.task('default', ['html', 'js', 'connect', 'sass','watch']);