-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
77 lines (63 loc) · 1.97 KB
/
Copy pathgulpfile.js
File metadata and controls
77 lines (63 loc) · 1.97 KB
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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var browserify = require('gulp-browserify');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var mocha = require('gulp-spawn-mocha');
// Update html
gulp.task('html', function() {
return gulp.src("app/*.html")
.pipe(gulp.dest("dist/"));
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("app/scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("dist/css"));
});
// process JS files and return the stream.
gulp.task('js', function () {
return gulp.src('./app/js/main.js')
.pipe(browserify())
.pipe(gulp.dest('./dist/js'));
});
// Copy local json data
gulp.task('data', function() {
return gulp.src("app/data/*.json")
.pipe(gulp.dest("dist/data"));
});
gulp.task('test', function() {
return gulp
.src(['test/*.js'], { read: false })
.pipe(mocha({
require: ['jsdom-global/register'],
reporter: 'min'//markdown, min
}));
});
// create a task that ensures the `js` task is complete before
// reloading browsers
gulp.task('js-watch', ['js'], function (done) {
browserSync.reload();
done();
});
gulp.task('sass-watch', ['sass'], function (done) {
browserSync.reload();
done();
});
gulp.task('html-watch', ['html'], function (done) {
browserSync.reload();
done();
});
// use default task to launch Browsersync and watch JS files
gulp.task('serve',['html','sass','js','data', 'test'], function () {
// Serve files from the root of this project
browserSync.init({
server: "./dist"
});
// add browserSync.reload to the tasks array to make
// all browsers reload after tasks are complete.
gulp.watch("app/js/**/*.js", ['js-watch','test']);
gulp.watch("app/scss/*.scss", ['sass-watch']);
gulp.watch("app/*.html",['html-watch']);
});
gulp.task('default', ['serve']);