-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
97 lines (81 loc) · 2.4 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const pump = require('pump');
const gulp = require('gulp');
const sass = require('gulp-sass');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');
const browserSync = require('browser-sync').create();
const gulpIf = require('gulp-if');
gulp.task('clean:css', () => {
return del(['public/css']);
});
gulp.task('clean:js', () => {
return del(['public/js']);
});
gulp.task('clean:html', () => {
return del(['public/index.html']);
});
gulp.task('clean:fonts', () => {
return del(['public/fonts/**']);
});
gulp.task('clean:images', () => {
return del(['public/images/**']);
});
gulp.task('clean:sounds', () => {
return del(['public/sounds/**']);
});
gulp.task('fonts', ['clean:fonts'], () => {
return gulp.src('src/fonts/**/*')
.pipe(gulp.dest('public/fonts'));
});
gulp.task('images', ['clean:images'], () => {
return gulp.src('src/images/**/*')
.pipe(gulp.dest('public/images'));
});
gulp.task('sounds', ['clean:sounds'], () => {
return gulp.src('src/sounds/**/*')
.pipe(gulp.dest('public/sounds'));
});
gulp.task('html', ['clean:html'], () => {
return gulp.src('src/index.html')
.pipe(gulp.dest('public/'));
});
gulp.task('css', ['clean:css'], done => {
pump([
gulp.src('src/scss/style.scss'),
gulpIf(!global.production, sourcemaps.init()),
sass({ outputStyle: 'compressed' }).on('error', sass.logError),
gulpIf(!global.production, sourcemaps.write()),
gulp.dest('public/css')
], done);
});
gulp.task('js', ['clean:js'], done => {
pump([
gulp.src('src/js/app.js'),
gulpIf(!global.production, sourcemaps.init()),
babel({
presets: ['env']
}),
uglify(),
gulpIf(!global.production, sourcemaps.write()),
gulp.dest('public/js')
], done);
});
gulp.task('build', ['images', 'sounds', 'html', 'css', 'js']);
gulp.task('deploy', () => {
global.production = true;
gulp.start(['build']);
});
gulp.task('default', ['build'], () => {
gulp.watch('src/images/**', ['images']);
gulp.watch('src/fonts/**', ['fonts']);
gulp.watch('src/sounds/**', ['sounds']);
gulp.watch('src/index.html', ['html']).on('change', browserSync.reload);
gulp.watch('src/scss/style.scss', ['css']).on('change', browserSync.reload);
gulp.watch('src/js/app.js', ['js']).on('change', browserSync.reload);
browserSync.init({
server: './public',
online: false
});
});