-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathgulpfile.js
More file actions
61 lines (52 loc) · 1.68 KB
/
Copy pathgulpfile.js
File metadata and controls
61 lines (52 loc) · 1.68 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
compass = require('gulp-compass'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
input = {
'html': 'source/*.html',
'sass': 'source/sass/**/*.scss',
'javascript': 'source/javascript/**/*.js'
},
output = {
'html': 'dist',
'stylesheets': 'dist/css',
'javascript': 'dist/js'
};
/* run javascript through jshint */
gulp.task('jshint', function() {
return gulp.src(input.javascript)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
/* concat javascript files, minify if --type production */
gulp.task('build-js', function() {
return gulp.src(input.javascript)
.pipe(concat('app.js'))
//only uglify if gulp is ran with '--type production'
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(gulp.dest(output.javascript));
});
/* compile scss files */
gulp.task('build-css', function() {
return gulp.src(input.sass)
.pipe(compass({
css: 'dist/css',
sass: 'source/sass'
}))
.pipe(gulp.dest(output.stylesheets));
});
/* copy any html files to dist */
gulp.task('copy-html', function() {
return gulp.src(input.html)
.pipe(gulp.dest(output.html));
});
/* Watch these files for changes and run the task on update */
gulp.task('watch', function() {
gulp.watch(input.javascript, ['jshint', 'build-js']);
gulp.watch(input.sass, ['build-css']);
gulp.watch(input.html, ['copy-html']);
});
/* run the watch task when gulp is called without arguments */
gulp.task('default', ['jshint', 'build-js', 'build-css', 'copy-html', 'watch']);