-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
78 lines (69 loc) · 2.22 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
`use strict`;
var gulp = require('gulp');
var browserify = require('browserify');
var ghPages = require('gulp-gh-pages');
var jade = require('gulp-jade');
var tap = require('gulp-tap');
var buffer = require('gulp-buffer');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var es = require('event-stream');
var maps = require('gulp-sourcemaps');
gulp.task('foo', function() {
gutil.log(gutil.env.prod === true);
});
gulp.task('browserifyMinify', function() {
return gulp.src(['js/fabric.js', 'js/app.js'], {base: './'})
.pipe(tap(function(file) {
gutil.log('bundling ' + file.path);
file.contents = browserify(file.path).bundle();
}))
.pipe(buffer())
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('jade', function() {
return gulp.src('index.jade')
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('./'));
});
gulp.task('sass', function() {
var task = gutil.env.prod ?
gulp.src('scss/style.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/css')) : gulp.src('scss/style.scss')
.pipe(maps.init())
.pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
.pipe(maps.write('.'))
.pipe(gulp.dest('css'));
if (!gutil.env.prod) {
var min = gulp.src('scss/style.scss')
.pipe(maps.init())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename({
suffix: '.min'
}))
.pipe(maps.write('./'))
.pipe(gulp.dest('css'));
}
return gutil.env.prod ? task : es.concat(task, min);
});
gulp.task('watchFiles', function() {
gulp.watch('js/*.js', ['browserifyMinify']);
gulp.watch('scss/style.scss', ['sass']);
gulp.watch('index.jade', ['jade']);
});
gulp.task('deploy', function() {
return gulp.src(['./assets/2.jpg', './dist/**/*', './index.html'], {base: './'})
.pipe(ghPages());
});