-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
122 lines (110 loc) · 3.8 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
webpack = require('gulp-webpack'),
jade = require('gulp-jade'),
autoprefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
stylus = require('gulp-stylus'),
koutoSwiss = require('kouto-swiss'),
path = require('path'),
iconify = require('gulp-iconify'),
gutil = require('gulp-util'),
minifyCSS = require('gulp-minify-css'),
gulpif = require('gulp-if'),
gzip = require('gulp-gzip'),
size = require('gulp-size'),
merge = require('merge-stream'),
langs = ['en','ru'];
gulp.task('stylus', function () {
return gulp.src('./src/stylus/main.styl')
.pipe(stylus({ use: [ koutoSwiss() ] }))
.pipe(gutil.env.type === 'production' ? minifyCSS() : gutil.noop())
.pipe(gulp.dest('./dist/css/'))
.pipe(reload({ stream : true }));
});
gulp.task('jade', function () {
var tasks = langs.map(function (lang) {
var dataPath = './src/data/'+lang
var data = {
meta: require(dataPath+'/meta.json'),
cover: require(dataPath+'/cover.json'),
slides: require(dataPath+'/slides.json'),
subscribeView: require(dataPath+'/subscribe.json'),
footer: require(dataPath+'/footer.json'),
// resources: require(dataPath+'/resources.json'),
// credits: require(dataPath+'/credits.json'),
// attributions: require(dataPath+'/attributions.json'),
// acknowledgements: require(dataPath+'/acknowledgements.json')
};
return gulp.src('./src/views/pages/*.jade')
.pipe(jade({locals: data}))
.pipe(gulp.dest('./dist/'+lang+'/'))
});
return merge(tasks);
});
gulp.task('index', function () {
return gulp.src('./dist/'+langs[0]+'/index.html')
.pipe(gulp.dest('./dist/'));
});
gulp.task('images', function () {
return gulp.src('./src/images/*.*')
.pipe(gulp.dest('./dist/images/'))
});
gulp.task('videos', function () {
return gulp.src('./src/videos/*.*')
.pipe(gulp.dest('./dist/videos/'))
});
gulp.task('iconify', function() {
return iconify({
src: './src/icons/*.svg',
cssOutput: './dist/css/',
pngOutput: './dist/images/icons/',
scssOutput: './dist/scss/'
});
});
gulp.task('js', function(){
return gulp.src('./src/js/index.js')
.pipe(webpack({
output : { filename : 'index.js' },
loaders: [
{ test: require.resolve('jquery'), loader: 'imports?jQuery=jquery' },
],
resolve : {
alias: {
TweenMax : path.join(__dirname + '/src/vendor/gsap/src/uncompressed/TweenMax.js'),
TweenLite : path.join(__dirname + '/src/vendor/gsap/src/uncompressed/TweenLite.js'),
TimelineMax : path.join(__dirname + '/src/vendor/gsap/src/uncompressed/TimelineMax.js')
}
}
}))
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('browser-sync', function() {
browserSync({
server: { baseDir: './dist/' },
port: 7200,
open: false
});
});
gulp.task('gzip', function () {
return gulp.src('./dist/**/*')
.pipe(size({title: 'build', gzip: true }))
.pipe(gulpif('*.js', gzip({ append: false })))
.pipe(gulpif('*.css', gzip({ append: false })))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', ['stylus','jade','js','iconify','images','videos'], function () {
return gulp.src('./dist/'+langs[0]+'/index.html')
.pipe(gulp.dest('./dist/'));
});
gulp.task('go', ['build','index','browser-sync'], function() {
gulp.watch('./src/stylus/**/*.styl', ['stylus']);
gulp.watch('./src/data/**/*.json', ['jade', reload]);
gulp.watch('./src/views/**/*.jade', ['jade', reload]);
gulp.watch('./src/js/**/*.js', ['js', reload]);
});