-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
64 lines (55 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
rev = require('gulp-rev'),
del = require('del');
var config = require('./gulp-config.json');
gulp.task('scripts', function () {
return gulp.src(config.paths.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('./assets/js/'))
.pipe(rev())
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('./assets/js/'))
.pipe(rev.manifest({base: './assets', merge: true}))
.pipe(gulp.dest('./assets/'));
});
gulp.task('styles', function () {
return gulp.src(config.paths.css)
.pipe(sass().on('error', sass.logError))
.pipe(concat('main.css'))
.pipe(gulp.dest('./assets/css/'))
.pipe(rev())
.pipe(rename({suffix: '.min'}))
.pipe(cssnano())
.pipe(gulp.dest('./assets/css/'))
.pipe(rev.manifest({base: './assets', merge: true}))
.pipe(gulp.dest('./assets/'));
});
gulp.task('fonts', function () {
return gulp.src(config.paths.fonts)
.pipe(gulp.dest('./assets/fonts/'));
});
gulp.task('images', function () {
return gulp.src(config.paths.images)
.pipe(gulp.dest('./assets/images/'));
});
gulp.task('watch', function () {
gulp.watch('src/sass/**/*.scss', ['styles']);
gulp.watch('src/js/**/*.js', ['scripts']);
});
// Clean
gulp.task('clean', function () {
return del(['./assets/css', './assets/js', './assets/fonts', './assets/images']);
});
// Default task
gulp.task('default', ['clean'], function () {
gulp.start('styles', 'scripts', 'fonts', 'images');
});