-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
55 lines (47 loc) · 1.69 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
/*eslint-env node */
var gulp = require('gulp'),
del = require('del'),
eslint = require('gulp-eslint'),
cssnano = require('gulp-cssnano'),
terser = require('gulp-terser'),
useref = require('gulp-useref'),
gulpif = require('gulp-if');
/** Default **/
gulp.task('default', ['lint', 'replace-html', 'copy-fonts', 'copy-images']);
/** Clean Distribution Folder **/
gulp.task('clean', function() {
return del(['public/dist/**/*']);
});
gulp.task('cleanDryRun', function() {
return del(['public/dist/**/*'], {dryRun: true}).then(paths => {
console.log('Files and folders that would be deleted:\n', paths.join('\n'));
});
});
/** JavasScript Linter **/
gulp.task('lint', function () {
return gulp.src(['public/src/js/app.js',
'public/src/js/xhrPromise.js',
'public/src/js/Hotel.js',
'public/src/js/ViewModel.js',
'public/src/js/MapView.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/** MINIFY, CONCAT, and REPLACE HTML **/
gulp.task('replace-html', ['lint'], function() {
return gulp.src('public/src/index.html')
.pipe(useref())
.pipe(gulpif('*.css', cssnano()))
.pipe(gulpif('*.js', terser()))
.pipe(gulp.dest('public/dist'));
});
/** COPY **/
gulp.task('copy-fonts', ['replace-html'], function() {
return gulp.src('public/src/fonts/*.*')
.pipe(gulp.dest('public/dist/fonts'));
});
gulp.task('copy-images', ['copy-fonts'], function() {
return gulp.src('public/src/images/*.*')
.pipe(gulp.dest('public/dist/images'));
});