-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (58 loc) · 1.85 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
68
69
70
71
72
73
let gulp = require('gulp'),
// server = require('gulp-server-livereload'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
useref = require('gulp-useref'),
gulpIf = require('gulp-if'),
csso = require('gulp-csso'),
uglify = require('gulp-uglifyes'),
imagemin = require('gulp-imagemin'),
clean = require('rimraf'),
browserSync = require('browser-sync').create(),
runSequence = require('run-sequence');
gulp.task("styles", function () {
gulp.src("./app/sass/**/*.sass")
.pipe(sass().on('error', sass.logError))
.pipe(prefix({
versions: ['last 20 versions']
}))
.pipe(gulp.dest('./app/css'))
.pipe(browserSync.stream());
});
gulp.task("images", function () {
gulp.src("./app/img/**/*")
.pipe(imagemin({
interlaced: true,
progressive: true,
optimizationLevel: 5
}))
.pipe(gulp.dest("./build/img"))
});
gulp.task("fonts", function () {
gulp.src("./app/fonts/**/*").pipe(gulp.dest("./build/fonts"));
})
gulp.task("clean", function (cb) {
clean('./build', cb);
});
gulp.task("build-html-js-css", function () {
gulp.src("./app/index.html")
.pipe(useref())
.pipe(gulpIf('*.css', csso()))
.pipe(gulpIf('*.js', uglify()))
.pipe(gulp.dest('./build'))
});
gulp.task('build', function (callback) {
runSequence('clean', ['images', 'fonts', 'build-html-js-css'], callback);
});
gulp.task("watch", function () {
gulp.watch("./app/sass/**/*.sass", ["styles"]);
});
// Static Server + watching scss/html files
gulp.task('serve', ['styles'], function () {
browserSync.init({
server: "./app"
});
gulp.watch("app/sass/**/*.sass", ['styles']);
gulp.watch("app/*.html").on('change', browserSync.reload);
});
gulp.task("default", ["serve"]);