-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathgulpfile.js
97 lines (87 loc) · 2.2 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
93
94
95
96
97
(function() {
'use strict'
/**
* Requirements
*/
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var cssmin = require('gulp-cssmin');
var jshint = require('gulp-jshint');
var notify = require("gulp-notify");
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
/**
* Paths
*/
var paths = {
sass: ['./sass/**/*.scss'],
scripts: ['./js/src/**/*.js']
};
/**
* Styles
*/
gulp.task('styles', function() {
return gulp.src(paths.sass)
.pipe(sass({
outputStyle: 'expanded'
}))
.on('error', notify.onError({
title: 'Error compiling Sass',
message: 'Check the console for info'
}))
.on('error', sass.logError)
.pipe(autoprefixer())
.pipe(gulp.dest('./css'))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./css'));
});
/**
* Styles watcher
*/
gulp.task('stylesDev', function() {
gulp.watch(paths.sass, ['styles']);
});
/**
* Scripts linting
*/
gulp.task('lint', function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.on('error', notify.onError({
title: 'JS hint failed',
message: 'Check the console for errors'
}));
});
/**
* Scripts uglify
*/
gulp.task('uglify', function() {
return gulp.src(paths.scripts)
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./js/dist/'));
});
/**
* Scripts dev
*/
gulp.task('scriptsDev', function() {
gulp.watch(paths.scripts, ['lint']);
});
/**
* Final tasks - these are the tasks that should be run from the command line,
* as they encompass the above.
*/
gulp.task('default', ['styles', 'lint', 'stylesDev', 'scriptsDev']);
gulp.task('styles:dev', ['styles', 'stylesDev']);
gulp.task('styles:build', ['styles']);
gulp.task('scripts:dev', ['lint', 'scriptsDev']);
gulp.task('scripts:build', ['lint', 'uglify']);
gulp.task('build', ['styles:build', 'scripts:build']);
})();