-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
48 lines (42 loc) · 1.28 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const del = require('del');
const autoprefixer = require('gulp-autoprefixer');
const minifycss = require('gulp-minify-css');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
const babel = require('gulp-babel');
gulp.task('clean', cb => {
del(['build'], cb);
});
gulp.task('browser-sync', () => {
browserSync.init({
server: './'
});
});
gulp.task('scripts', () => {
return gulp.src('src/js/*')
.pipe(babel({
presets: ['es2015'],
}))
.pipe(uglify())
.pipe(gulp.dest('build/js/'))
.pipe(browserSync.stream());
});
gulp.task('styles', () => {
return gulp.src('src/scss/*')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(minifycss())
.pipe(gulp.dest('build/css/'))
.pipe(browserSync.stream());
});
gulp.task('watch', () => {
gulp.watch('src/js/**/*', ['scripts']);
gulp.watch('src/scss/**/*', ['styles']);
gulp.watch('index.html', reload);
});
gulp.task('default', ['watch', 'scripts', 'styles', 'browser-sync']);