forked from katdiese/trove-FE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (74 loc) · 1.82 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
// *** dependencies *** //
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var connect = require('gulp-connect');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var runSequence = require('run-sequence');
// *** tasks *** ///
gulp.task('connect', function () {
connect.server({
root: './src/',
port: 8888,
livereload: true
});
});
gulp.task('connectDist', function () {
connect.server({
root: './dist/',
port: 9999,
livereload: true
});
});
gulp.task('html', function () {
gulp.src('./src/*.html')
.pipe(connect.reload());
});
gulp.task('css', function () {
gulp.src('./src/css/*.css')
.pipe(connect.reload());
});
gulp.task('jshint', function() {
return gulp.src('./src/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('watch', function() {
gulp.watch('./src/js/*.js', ['jshint']);
gulp.watch(['./src/*.html'], ['html']);
gulp.watch(['./src/css/*.css'], ['css']);
});
gulp.task('clean', function() {
gulp.src('./dist/*')
.pipe(clean({force: true}));
});
gulp.task('minify-css', function() {
var opts = {comments:true, spare:true};
gulp.src('./src/css/*.css')
.pipe(minifyCSS(opts))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('minify-js', function() {
gulp.src('./src/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('copy-html-files', function () {
gulp.src('./src/*.html')
.pipe(gulp.dest('./dist/'));
});
// *** default *** //
gulp.task('default', ['watch', 'connect']);
// *** build task *** //
gulp.task('build', function() {
runSequence(
['clean'],
['jshint'],
['minify-css'],
['minify-js'],
['copy-html-files'],
['connectDist']
);
});