This repository has been archived by the owner on Jun 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
92 lines (80 loc) · 2.33 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
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
path = require('path'),
browserSync = require('browser-sync'),
through2 = require('through2'),
reload = browserSync.reload,
browserify = require('browserify'),
del = require('del'),
argv = require('yargs').argv,
sass = require('gulp-sass');
gulp.task('browser-sync', function() {
browserSync({
open: !!argv.open,
notify: !!argv.notify,
server: {
baseDir: './dist'
}
});
});
gulp.task('sass', function() {
return gulp.src('./src/stylesheets/**/*.{scss,sass}')
.pipe($.plumber())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/stylesheets'));
});
gulp.task('js', function() {
return gulp.src([
'src/scripts/main.js'
])
.pipe($.plumber())
.pipe(through2.obj(function (file, enc, next) {
browserify(file.path, { debug: true })
.transform(require('babelify'))
.transform(require('debowerify'))
.bundle(function (err, res) {
if (err) { return next(err); }
file.contents = res;
next(null, file);
});
}))
.on('error', function (error) {
console.log(error.stack);
this.emit('end')
})
.pipe($.rename('app.js'))
.pipe(gulp.dest('dist/scripts/'));
});
gulp.task('clean', function(cb) {
del('./dist', cb);
});
gulp.task('images', function() {
gulp.src('./src/libs/**/*')
.pipe(gulp.dest('./dist/libs'))
return gulp.src('./src/images/**/*')
.pipe($.imagemin({
progressive: true
}))
.pipe(gulp.dest('./dist/images'))
})
gulp.task('templates', function() {
return gulp.src('src/**/*.html')
.pipe($.plumber())
.pipe( gulp.dest('dist/'))
});
gulp.task('copy', function() {
return gulp.src([
'src/scripts/recorder.js',
'src/scripts/recorderWorker.js'
])
.pipe($.rename({dirname: ''}))
.pipe(gulp.dest('dist/scripts'));
});
gulp.task('build', ['sass', 'js', 'copy', 'templates']);
gulp.task('serve', ['build', 'browser-sync'], function () {
gulp.watch('src/stylesheets/**/*.{scss,sass}',['sass', reload]);
gulp.watch('src/scripts/**/*.js',['js', reload]);
gulp.watch('src/images/**/*',['images', reload]);
gulp.watch('src/*.html',['templates', reload]);
});
gulp.task('default', ['serve']);