-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
165 lines (148 loc) · 4.39 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
var gulp = require('gulp'),
// gulp modules
autoprefixer = require('gulp-autoprefixer'),
bower = require('gulp-bower'),
concat = require('gulp-concat'),
imagemin = require('gulp-imagemin'),
jade = require('gulp-jade'),
less = require('gulp-less'),
livereload = require('gulp-livereload'),
minifyCss = require('gulp-minify-css'),
newer = require('gulp-newer'),
plumber = require('gulp-plumber'),
run = require('gulp-run'),
uglifyJs = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
// image optimizers
jpegtran = require('imagemin-jpegtran'),
optipng = require('imagemin-optipng'),
svgo = require('imagemin-svgo'),
// native modules
del = require('del'),
runSequence = require('run-sequence');
/**
* Installation tasks
*/
gulp.task('install-bower', function () {
return bower();
});
gulp.task('install', ['install-bower']);
/**
* Build templates tasks
*/
gulp.task('clean-templates', function (cb) {
del(['./**/*.html'], cb);
});
gulp.task('build-templates', function () {
return gulp.src(
[
'sources/pages/**/*.jade'
],
{base: 'sources/pages'})
.pipe(plumber())
.pipe(jade())
.pipe(gulp.dest('.'));
});
/**
* Build stylesheets tasks
*/
gulp.task('clean-stylesheets', function (cb) {
del(['stylesheets'], cb);
});
gulp.task('build-stylesheets', function () {
return gulp.src('sources/stylesheets/tenside.less')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(less({
compress: true
}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(sourcemaps.write('.', {sourceRoot: '../sources/stylesheets'}))
.pipe(gulp.dest('stylesheets'));
});
/**
* Build javascripts tasks
*/
gulp.task('clean-javascripts', function (cb) {
del(['javascripts'], cb);
});
gulp.task('build-javascripts', function () {
return gulp.src(
[
'/home/tristan/workspace/tenside/tenside.github.io/bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'sources/javascripts/**/*.js'
])
.pipe(plumber())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglifyJs())
.pipe(concat('tenside.js'))
.pipe(sourcemaps.write('.', {sourceRoot: '../sources/javascripts'}))
.pipe(gulp.dest('javascripts'));
});
/**
* Build images tasks
*/
gulp.task('clean-images', function (cb) {
del(['images'], cb);
});
gulp.task('build-images', function () {
return gulp.src(
[
'sources/images/**/*.{jpg,png,svg}'
],
{base: 'sources/images'})
.pipe(plumber())
.pipe(newer('images'))
// TODO imagemin break contao logo
// .pipe(imagemin({
// use: [jpegtran(), optipng(), svgo()]
// }))
.pipe(gulp.dest('images'));
});
/**
* Build fonts task
*/
gulp.task('clean-fonts', function (cb) {
del(['fonts'], cb);
});
gulp.task('build-fonts', function () {
return gulp.src(['bower_components/font-awesome/fonts/*', 'bower_components/bootstrap-material-design/dist/fonts/Material-Design-Icons.*'])
.pipe(plumber())
.pipe(newer('fonts'))
.pipe(gulp.dest('fonts'));
});
/**
* Global build tasks
*/
gulp.task('clean', ['clean-templates', 'clean-stylesheets', 'clean-javascripts', 'clean-images', 'clean-fonts']);
gulp.task('build', function () {
runSequence(
'clean',
['build-templates', 'build-stylesheets', 'build-javascripts', 'build-images', 'build-fonts']
);
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch(['sources/pages/**/*.jade', 'sources/templates/**/*.jade'], function() {
runSequence('build-templates', livereload.changed);
});
gulp.watch('sources/stylesheets/**/*.less', function() {
runSequence('build-stylesheets', livereload.changed);
});
gulp.watch('sources/javascripts/**/*.less', function() {
runSequence('build-javascripts', livereload.changed);
});
gulp.watch('sources/images/**/*', function() {
runSequence('build-images', livereload.changed);
});
});
gulp.task('default', function () {
runSequence(
['build-templates', 'build-stylesheets', 'build-javascripts', 'build-images', 'build-fonts'],
'watch'
);
});