-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgulpfile.js
67 lines (57 loc) · 1.83 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
var pngquant = require('imagemin-pngquant');
var del = require('del');
var browserSync = require('browser-sync');
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var jade = require('gulp-jade');
var uglify = require('gulp-uglify');
var cssnano = require('gulp-cssnano');
var concatJs = require('gulp-concat');
var concatCss = require('gulp-concat-css');
gulp.task('clean', function(){
return del.sync('./dist');
});
gulp.task('jade', function(){
gulp.src('./src/views/pages/*.jade')
.pipe(jade())
.pipe(gulp.dest('./dist/'));
});
gulp.task('css', function(){
gulp.src(['./src/styles/vendor/*.css', './src/styles/*.css'])
.pipe(concatCss('styles.css'))
.pipe(cssnano())
.pipe(gulp.dest('./dist/styles/'));
});
gulp.task('js', function(){
gulp.src(['./src/scripts/vendor/*.js', './src/scripts/*.js'])
.pipe(concatJs('scripts.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/scripts/'));
});
gulp.task('imagemin', function(){
gulp.src('src/images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('dist/images'));
});
gulp.task('fonts', function(){
gulp.src('./src/fonts/**/*')
.pipe(gulp.dest('./dist/fonts/'));
});
gulp.task('watch', function(){
browserSync({
server: './dist',
baseDir: '/',
port: 4000,
notify: false
});
gulp.watch('./src/views/**/*', ['jade']).on('change', browserSync.reload);
gulp.watch('./src/scripts/**/*', ['js']).on('change', browserSync.reload);
gulp.watch('./src/styles/**/*', ['css']).on('change', browserSync.reload);
gulp.watch('./src/fonts/**/*', ['fonts']).on('change', browserSync.reload);
});
gulp.task('build', ['clean', 'imagemin', 'jade', 'css', 'js', 'fonts']);
gulp.task('default', ['build', 'watch']);