-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathgulpfile.js
63 lines (52 loc) · 1.3 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var pump = require('pump');
var del = require('del');
var rename = require('gulp-rename');
// Path settings.
var paths = {
sass: './pages/src/sass',
css: './pages/dist/css',
js_src: './pages/src/js',
js_dist: './pages/dist/js'
};
var options = {
sass: {
outputStyle: 'compressed'
},
uglify: {
output: {
quote_style: 1
}
}
};
gulp.task('clean-css', function() {
del.sync([paths.css + '/*']);
});
gulp.task('clean-js', function() {
del.sync([paths.js_dist + '/*']);
});
gulp.task('clean', ['clean-css', 'clean-js']);
gulp.task('compile-css', ['clean-css'], function() {
return gulp.src(paths.sass + '/**/*.scss')
.pipe(sass(options.sass).on('error', sass.logError))
.pipe(gulp.dest(paths.css));
});
gulp.task('compile-js', ['clean-js'], function(cb) {
pump([
gulp.src(paths.js_src + '/*.js'),
rename({suffix: '.min'}),
uglify(options.uglify),
gulp.dest(paths.js_dist)
],
cb
);
});
gulp.task('compile', ['compile-css', 'compile-js']);
gulp.task('watch', function() {
gulp.watch(paths.sass + '/**/*.scss', ['compile-css']);
gulp.watch(paths.js_src + '/**/*.js', ['compile-js']);
});
gulp.task('default', ['compile', 'watch']);