-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (59 loc) · 2.09 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
75
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const del = require('del');
const runSequence = require('run-sequence');
const ghPages = require('gulp-gh-pages');
const plugins = require('gulp-load-plugins')();
const dev = true;
const { reload } = browserSync;
const distDir = "dist";
gulp.task('styles', () => gulp.src('src/css/**/*.css')
.pipe(gulp.dest(`${distDir}/css`))
.pipe(reload({ stream: true })));
function lint(files) {
return gulp.src(files)
.pipe(plugins.eslint({ fix: true }))
.pipe(plugins.eslint.format());
}
gulp.task('lint', () =>
lint('src/js/**/*.js')
.pipe(gulp.dest('src')));
gulp.task('scripts', ['lint'], () => gulp.src('src/js/**/*.js')
.pipe(plugins.plumber())
.pipe(plugins.if(dev, plugins.sourcemaps.init()))
.pipe(plugins.babel())
.pipe(plugins.if(dev, plugins.sourcemaps.write('.')))
.pipe(gulp.dest(`${distDir}/js`))
.pipe(reload({ stream: true })));
gulp.task('vendors', () => gulp.src('src/vendor/**/*')
.pipe(gulp.dest(`${distDir}/vendor`))
.pipe(reload({ stream: true })));
gulp.task('data', () => gulp.src('src/**/*.json')
.pipe(gulp.dest(`${distDir}`))
.pipe(reload({ stream: true })));
gulp.task('html', ['styles', 'scripts'], () => gulp.src('src/**/*.html')
.pipe(gulp.dest(`${distDir}`))
.pipe(reload({ stream: true })));
gulp.task('clean', del.bind(null, ['.tmp']));
gulp.task('serve', () => {
runSequence(['clean'], ['styles', 'scripts', 'vendors', 'data', 'html'], () => {
browserSync.init({
notify: false,
port: 8080,
server: {
baseDir: [`${distDir}`, 'src'],
},
});
// Reloads the browser whenever HTML or CSS files change
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/css/**/*.css', ['styles']);
gulp.watch('src/js/**/*.js', ['scripts']);
gulp.watch('src/**/*.json', ['data']);
gulp.watch('src/vendor/**/*', ['vendors']);
});
});
gulp.task('publish', () => gulp.src(`${distDir}/**/*`)
.pipe(ghPages()));
gulp.task('deploy', () => {
runSequence(['clean'], ['styles', 'scripts', 'vendors', 'html'], ['publish']);
});