-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
42 lines (32 loc) · 1.21 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
'use strict';
const gulp = require('gulp');
const tar = require('gulp-tar'); // https://www.npmjs.com/package/gulp-tar
const gzip = require('gulp-gzip'); // https://www.npmjs.com/package/gulp-gzip
const notify = require('gulp-notify');
const browserSync = require('browser-sync').create();
const del = require('del');
const distPath = 'dist/';
gulp.task('clean', () =>
del(['dist/**'])
);
gulp.task('copyFiles', () =>
gulp.src('./src/**/*')
.pipe(gulp.dest(distPath))
);
gulp.task('browser-sync', () => {
browserSync.init(['dist/css/**.css', 'dist/js/**.js', 'dist/**.html'], { // Look for changes in dist directories
server: 'dist' // Reload browser when any JS is modified or inject CSS when any stylesheet is modified
});
});
gulp.task('watch', ['browser-sync'], () => {
gulp.watch(['src/css/*.css', 'src/js/*.js', 'src/*.html'], ['copyFiles']);
});
gulp.task('compress', () =>
gulp.src('dist/*')
.pipe(tar('code.tar')) // Pack all the files together
.pipe(gzip()) // Compress the package using gzip
.pipe(gulp.dest('.'))
.pipe(notify('Compressed package generated!'))
);
gulp.task('deploy', ['copyFiles', 'compress']);
gulp.task('default', ['copyFiles']);