-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (57 loc) · 1.45 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
const gulp = require('gulp');
const cleanCss = require('gulp-clean-css');
const concat = require('gulp-concat');
const plumber = require('gulp-plumber');
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync');
const uglify = require('gulp-uglify');
const jshint = require('jshint');
const stylish = require('jshint-stylish');
const onError = err => {
console.log(`Error -> ${err}`);
}
gulp.task('css', () => {
return gulp.src('./css/**/*.css')
.pipe(plumber({
errorHandler: onError()
}))
.pipe(sourcemaps.init())
.pipe(concat('style.css'))
.pipe(cleanCss({
compatibility: 'ie9'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist', {
overwrite: true
}))
.pipe(browserSync.stream())
});
gulp.task('js', () => {
return gulp.src('./js/**/*.js')
.pipe(plumber({
errorHandler: onError()
}))
.pipe(sourcemaps.init())
.pipe(concat('index.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist', {
overwrite: true
}))
.pipe(browserSync.stream())
});
gulp.task('watch', ['css', 'js'], () => {
console.log('watching files');
const files = [
'./css/**/*.css',
'./js/**/*.js'
];
browserSync.init(files, {
proxy: "web:80",
notify: true,
open: false
});
gulp.watch(['./css/**/*.css'], ['css']);
gulp.watch(['./js/**/*.js'], ['js']);
});
gulp.task('default', ['css', 'js']);