-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
76 lines (64 loc) · 1.77 KB
/
gulpfile.js
File metadata and controls
76 lines (64 loc) · 1.77 KB
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
76
const gulp = require('gulp');
const concat = require('gulp-concat');
const notify = require('gulp-notify');
const browserSync = require('browser-sync');
const jshint = require('gulp-jshint');
const paths = {
assets: ['./src/assets/'],
scripts: ['./src/js/main.js', './src/**/*.js'],
html: ['./src/html/*.html', './src/html/index.html'],
styles: ['./src/css/styles.css', './src/css/*.css']
};
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: './public'
}
});
});
gulp.task('js:lint', function() {
return gulp
.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(notify({ message: 'jshint done' }));
});
gulp.task('js:build', function() {
return gulp
.src(paths.scripts)
.pipe(concat('main.js'))
.pipe(gulp.dest('./public/js'))
.pipe(notify({ message: 'JS concated' }));
});
gulp.task('js:watch', ['js:build'], function(done) {
browserSync.reload();
done();
});
gulp.task('html:build', function() {
return gulp
.src(paths.html)
.pipe(gulp.dest('./public/'))
.pipe(notify({ message: 'HTML pages built' }));
});
gulp.task('html:watch', ['html:build'], function(done) {
browserSync.reload();
done();
});
gulp.task('css:build', function() {
return gulp
.src(paths.styles)
.pipe(concat('styles.css'))
.pipe(gulp.dest('./public/css'))
.pipe(notify({ message: 'CSS done' }));
});
gulp.task('css:watch', ['css:build'], function(done) {
browserSync.reload();
done();
});
gulp.task('build', ['html:build', 'js:build', 'css:build']);
gulp.task('watch', function() {
gulp.watch(paths.html, ['html:watch']);
gulp.watch(paths.scripts, ['js:lint', 'js:watch']);
gulp.watch(paths.styles, ['css:watch']);
});
gulp.task('default', ['build', 'serve', 'watch']);