-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (66 loc) · 1.8 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
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const uglify = require('gulp-uglify');
const ghPages = require('gulp-gh-pages');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const browserSync = require('browser-sync');
const bs = browserSync.create();
/* config
---------------------------------------------------- */
// CSS Task
gulp.task('css', () => {
return gulp.src('src/css/*.css')
.pipe(autoprefixer({
overrideBrowserslist: ['> 1%', 'last 3 versions'],
cascade: false
}))
.pipe(cleanCSS())
.pipe(gulp.dest('dist'))
.pipe(bs.stream());
});
// JS Task
gulp.task('js', () => {
return browserify({
entries: ['./src/js/calendar.js'],
standalone: 'Calendar'
})
.transform(babelify, {
presets: ['@babel/preset-env'],
global: true,
})
.bundle()
.on('error', function (err) {
console.error(err);
this.emit('end');
})
.pipe(source('calendar.js'))
.pipe(gulp.dest('dist'));
});
// Watch JS and reload browser
gulp.task('js-watch', gulp.series('js', (done) => {
bs.reload();
done();
}));
// Deploy Task
gulp.task('deploy', () => {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
// Serve Task
gulp.task('serve', () => {
bs.init({
server: {
baseDir: './dist'
}
});
});
// Watch Task
gulp.task('watch', gulp.parallel('serve', () => {
gulp.watch('src/css/*.css', gulp.series('css'));
gulp.watch('src/js/*.js', gulp.series('js-watch'));
}));
// Default Task
gulp.task('default', gulp.parallel('css', 'js'));