-
Notifications
You must be signed in to change notification settings - Fork 13
/
gulpfile.js
89 lines (75 loc) · 2.7 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* @Author: Ali
* @Date: 2017-02-26 10:38:27
* @Last Modified by: Ali
* @Last Modified time: 2017-02-26 23:17:31
*/
'use strict';
const gulp = require('gulp');
const imagemin = require('gulp-imagemin');
const sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat');
const jsmin = require('gulp-jsmin');
const processhtml = require('gulp-processhtml');
const htmlmin = require('gulp-htmlmin');
// const watch = require('gulp-watch');
const path = require('path');
const jsdoc = require('gulp-jsdoc3');
const ghpages = require('gh-pages');
// html
gulp.task('process-html', () => {
return gulp.src('./app/*.html').pipe(processhtml()).pipe(gulp.dest('./public'));
});
gulp.task('minify-html', ['process-html'],() => {
return gulp.src('./public/*.html').pipe(htmlmin({collapseWhitespace: true})).pipe(gulp.dest('./public'));
});
// css
gulp.task('sass', () => {
return gulp.src('./app/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./app/scss/css'));
});
gulp.task('concat-css', ['sass'],() => {
return gulp.src(['./node_modules/bootstrap/dist/css/bootstrap.css', './app/scss/css/**/*']).pipe(concat('main.css')).pipe(gulp.dest('./public/css'));
});
gulp.task('minify-css', ['concat-css'], () => {
return gulp.src('./public/css/main.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('./public/css'));
});
// images
gulp.task('images', () => {
return gulp.src('app/images/**/*').pipe(imagemin()).pipe(gulp.dest('public/images'));
}
);
// JS
gulp.task('js-concat', () => {
return gulp.src(['./node_modules/angular/angular.js','./app/js/app.js', './app/js/services/santafactory.js', './app/js/controllers/secret-santa.js']).pipe(concat('main.js')).pipe(gulp.dest('./public/js'));
});
gulp.task('minify-js', ['js-concat'], () => {
gulp.src('./public/js/main.js')
.pipe(jsmin())
.pipe(gulp.dest('public/js'));
});
// watcher
// Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch('./app/*.html', ['minify-html']);
gulp.watch('./app/scss/**/*.scss', ['minify-css']);
gulp.watch('./app/js/**/*', ['minify-js']);
gulp.watch('./app.images/**/*', ['images']);
});
// docs
gulp.task('build-doc', (cb) => {
var config = require('./jsdoc.conf.json');
gulp.src(['./app/js/**/*.js', './server.js', './routes/route.js'], {read: false})
.pipe(jsdoc(config , cb));
});
gulp.task('publish-doc', ['build-doc'], () => {
ghpages.publish(path.join(__dirname, 'out'), console.error);
});
// default
gulp.task('default', ['images', 'minify-js', 'minify-css', 'minify-html'], () => {
// This will only run if the dependency tasks are successful...
});