-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (57 loc) · 1.74 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
'use strict';
var gulp = require('gulp');
var autoPrefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var imageMin = require('gulp-imagemin');
var rename = require('gulp-rename');
var sourceMaps = require('gulp-sourcemaps');
var cleanCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var server = require('gulp-server-livereload');
var newer = require('gulp-newer');
gulp.task('sass', function () {
return gulp.src('src/scss/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename('afterSass.css'))
.pipe(gulp.dest('src/css'));
});
gulp.task('concat', function() {
return gulp.src('src/css/*.css')
.pipe(autoPrefixer())
.pipe(concat('styles.min.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('dist/css'));
});
gulp.task('pages', function(){
return gulp.src('src/*.html')
.pipe(gulp.dest('dist'))
});
gulp.task('images', function(){
return gulp.src('src/images/**/*.{jpg,png,gif}')
.pipe(newer('dist/images/**'))
.pipe(imageMin())
.pipe(gulp.dest('dist/images'))
});
gulp.task('scripts', function() {
return gulp.src('src/js/*.js')
.pipe(concat('bundle.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
});
gulp.task('webserver', function() {
gulp.src('dist')
.pipe(server({
livereload: true,
directoryListing: false,
open: true,
defaultFile: 'index.html'
}));
});
gulp.task('default', function() {
gulp.start('pages', 'sass', 'concat', 'images', 'scripts', 'webserver');
gulp.watch('src/*.html', ['pages']);
gulp.watch('src/scss/*.scss', ['sass']);
gulp.watch('src/css/*.css', ['concat']);
gulp.watch('src/js/*.js', ['scripts']);
});