-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
64 lines (47 loc) · 1.53 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
var gulp = require("gulp");
var babel = require("gulp-babel");
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var rename = require("gulp-rename");
gulp.task( 'prodJS', function () {
return gulp.src('src/dev/js/*.js')
.pipe(uglify().on('error', console.error))
.pipe(rename(function (path) {
path.basename += '.min';
return path;
}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('sass', function () {
return gulp.src('src/scss/**/*.scss')
.pipe(sass({outputStyle: 'nested'}).on('error', sass.logError))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream());
});
gulp.task('dev', function () {
return gulp.src('src/js/*.js')
.pipe(babel())
// .pipe(concat('dbox.js'))
.pipe(gulp.dest('src/dev/js'))
.pipe(browserSync.stream());
});
gulp.task('watch', function() {
gulp.watch('src/js/**/**/*.js', gulp.series('dev'));
gulp.watch('src/scss/**/**/*.scss', gulp.series('sass'));
});
gulp.task('js-watch', gulp.series('dev', function (done) {
browserSync.reload();
done();
}));
gulp.task('serve', gulp.series('dev', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch('src/scss/**/**/*.scss', gulp.series('sass'));
gulp.watch('src/js/**/**/*.js', gulp.series('dev'));
gulp.watch("*.html").on('change', browserSync.reload);
}));
gulp.task('default', gulp.series('serve'));