-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (64 loc) · 2.14 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
const gulp = require('gulp'),
notify = require('gulp-notify'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
del = require('del'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync'),
babel = require('gulp-babel'),
sourcemaps = require('gulp-sourcemaps');
gulp.task('browser-sync', function() {
return browserSync({
server: {
baseDir: 'src'
},
notify: false,
open: false,
reloadOnRestart: true
});
});
gulp.task('js', function() {
return gulp.src([
'src/js/gh-notify.js',
'src/js/common.js',
])
.pipe(rename({ suffix: '.min', prefix: '' }))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('src/js'))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task('sass', function() {
return gulp.src('src/sass/**/*.sass')
.pipe(rename({ suffix: '.min', prefix: '' }))
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'expand' }).on("error", notify.onError()))
.pipe(autoprefixer(['last 15 versions']))
.pipe(cleanCSS()) // Опционально, закомментировать при отладке
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
gulp.watch(['src/js/**/*.js', '!src/js/**/*.min.js'], ['js']);
gulp.watch('src/sass/**/*.sass', ['sass']);
gulp.watch('src/**/*.html', browserSync.reload);
});
gulp.task('build', ['sass', 'js'], function() {
var buildCss = gulp.src([
'src/css/gh-notify.min.css',
])
.pipe(gulp.dest('build/'));
var buildJs = gulp.src([
'src/js/gh-notify.min.js'
])
.pipe(gulp.dest('build/'));
});
gulp.task('default', ['watch']);