-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
56 lines (47 loc) · 1.48 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
// Grab our gulp packages
var gulp = require('gulp'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass');
var input = {
'sass': 'src/scss/**/*.scss',
'javascript': 'src/js/**/*.js',
},
output = {
'stylesheets': 'build/css',
'javascript': 'build/js'
};
// Create a default task and add the watch to it
gulp.task('default', ['watch']);
// Configure the jshint task
gulp.task('jshint', function() {
return gulp.src(input.javascript)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
/* compile scss files */
gulp.task('build-css', function() {
return gulp.src(input.sass)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(gulp.dest(output.stylesheets));
});
/* Concat javascript files, minify if --type production */
gulp.task('build-js', function() {
return gulp.src(input.javascript)
.pipe(sourcemaps.init())
//only uglify if gulp is ran with '--type production'
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(concat('app.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(output.javascript));
});
// Configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch(input.javascript, ['jshint', 'build-js']);
gulp.watch(input.sass, ['build-css']);
});