-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (51 loc) · 1.79 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
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
del = require('del'),
browserSync = require('browser-sync').create();
gulp.task('default', ['clean', 'styles', 'scripts', 'images', 'watch'], function() {
browserSync.init({
proxy: "localhost:8000"
});
gulp.watch('**/*.html').on('change', browserSync.reload);
gulp.watch(['static/**']).on('change', browserSync.reload);
});
gulp.task('styles', function() {
return sass('assets/sass/main.scss', { style: 'expanded' })
.pipe(autoprefixer('last 2 version'))
.pipe(gulp.dest('static/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('static/css'))
});
gulp.task('scripts', function() {
return gulp.src('assets/js/**/*.js')
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('static/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('static/js'))
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('images', function() {
return gulp.src('assets/img/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('static/img'))
});
gulp.task('clean', function() {
return del(['static/css', 'static/js', 'static/img']);
});
gulp.task('watch', function() {
gulp.watch('assets/sass/**/*.scss', ['styles']);
gulp.watch('assets/js/**/*.js', ['scripts']);
gulp.watch('assets/img/**/*', ['images']);
});