forked from lyontechhub/lyontechhub.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
124 lines (109 loc) · 3.81 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var gulp = require('gulp');
var del = require('del')
var deploy = require("gulp-gh-pages");
var less = require("gulp-less");
var amdOptimize = require('amd-optimize');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var argv = require('yargs').argv;
var gulpIf = require('gulp-if');
var minifyCSS = require('gulp-minify-css');
var git = require('gulp-gh-pages/lib/git');
var gutil = require('gulp-util');
var when = require('when');
var path = require('path');
var runSequence = require('run-sequence');
/* Configuration */
var lessSource = 'css/main.less';
var jsSource = 'js/**/*.js';
var htmlSource = ['views/*.html', 'index.html'];
var assetsSource = ['imgs/**/*', 'data/**/*'];
var destDir = 'dist/';
var deployOptions = {
"origin": 'origin',
"branch": "master"
}
var tmpRepoPath = '';
/* Tasks */
gulp.task('clean', function () {
del('dist', true);
});
gulp.task('build-css', function () {
return gulp.src(lessSource, { base: './' })
.pipe(less({ paths: [ 'bower_components/bootstrap/less/' ] }))
.pipe(gulpIf(argv.push, minifyCSS()))
.pipe(gulp.dest(destDir));
});
gulp.task('watch-css', function() {
gulp.watch(lessSource, ['build-css']);
});
gulp.task('build-js', function () {
return gulp.src(jsSource, { base: './' })
.pipe(amdOptimize('main', {
baseUrl: 'js',
paths: {
'jquery': 'empty:',
'bootstrap': 'empty:',
'domReady': 'empty:',
'angular': 'empty:',
'angularRoute': 'empty:',
'angularSanitize': 'empty:',
'angularStrapNavBar': '../bower_components/angular-strap/dist/modules/navbar',
'angulartics': '../bower_components/angulartics/dist/angulartics.min',
'angulartics.google.analytics': '../bower_components/angulartics/dist/angulartics-ga.min'
},
shim: {
'bootstrap': {
deps: ['jquery']
},
'angular': {
deps: ['jquery'],
exports: 'angular'
},
'angularRoute': {
deps: ['angular']
},
'angularSanitize': {
deps: ['angular']
},
'angularStrapNavBar': {
deps: ['angular']
},
'angulartics': {
deps: ['angular']
},
'angulartics.google.analytics': {
deps: ['angulartics']
}
}}))
.pipe(concat('js/build.min.js'))
.pipe(gulpIf(argv.push, uglify()))
.pipe(gulp.dest(destDir));
});
gulp.task('watch-js', function() {
gulp.watch(jsSource, ['build-js']);
});
gulp.task('build-html', function () {
return gulp.src(htmlSource, { base: './' })
.pipe(gulp.dest(destDir));
});
gulp.task('watch-html', function() {
gulp.watch(htmlSource, ['build-html']);
});
gulp.task('copy-assets', function() {
return gulp.src(assetsSource, { base: './'})
.pipe(gulp.dest(destDir));
});
gulp.task('watch-assets', function() {
gulp.watch(assetsSource, ['copy-assets']);
});
gulp.task('build', ['build-css', 'build-js', 'build-html', 'copy-assets']);
gulp.task('watch', ['watch-css', 'watch-js', 'watch-html', 'watch-assets']);
// Deploy target to use to deploy to github pages (not used -> no SEO solution, heroku is used instead)
gulp.task('deploy', function () {
runSequence('build', function() {
deployOptions.push = argv.push ? true : false;
return gulp.src(['./dist/**/*'])
.pipe(deploy(deployOptions));
})
});