-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
55 lines (48 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
// Imports
var gulp = require('gulp'),
less = require('gulp-less'),
uglify = require('gulp-uglify'),
del = require('del'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps');
// Paths
var paths = {
scripts: 'js/*.js',
styles: 'less/*.less',
dependencies: ['bower_components/jquery/dist/jquery.js', 'bower_components/Snap.svg/dist/snap.svg.js']
};
// Clean the build directory
gulp.task('clean', function(cb) {
del(['dist/**/*'], cb);
});
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
return gulp.src(paths.scripts)
.pipe(gulp.dest('dist/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
});
// Compile LESS
gulp.task('styles', function() {
return gulp.src(paths.styles)
.pipe(less())
.pipe(gulp.dest('dist/css'));
});
// Minify all the vendor dependencies
gulp.task('dependencies', function() {
return gulp.src(paths.dependencies)
.pipe(uglify())
.pipe(concat('dependencies.min.js'))
.pipe(gulp.dest('dist/js/vendor'));
});
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.styles, ['styles']);
});
// Default task
gulp.task('default', ['clean', 'scripts', 'styles', 'dependencies', 'watch']);