forked from openSUSE/landing-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (81 loc) · 3.14 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
// Include gulp
var gulp = require('gulp');
// Define main directories
var assets = 'assets/';
var destination = 'build/';
// Concatenate & Minify JS
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var stripDebug = require('gulp-strip-debug');
gulp.task('scripts', function() {
return gulp.src([assets + 'js/vendor/jquery.min.js',
assets + 'js/vendor/bootstrap.min.js',
assets + 'js/vendor/jquery.easing.1.3.js',
assets + 'js/vendor/smoothscroll.js',
assets + 'js/vendor/owl.carousel.min.js',
assets + 'js/vendor/wow.js',
assets + 'js/vendor/Modernizr.custom.js',
assets + 'js/vendor/jquery-cookie.js',
assets + 'js/vendor/jquery-lang.js',
assets + 'js/vendor/jquery.mobile.custom.js',
assets + 'js/vendor/jquery.countdown.min.js',
assets + 'js/vendor/moment.js',
assets + 'js/vendor/moment-timezone-with-data.js',
assets + 'js/opensuse-news.js',
assets + 'js/countdown.js',
assets + 'js/opensuse-theme.js'])
.pipe(concat('main.js'))
.pipe(rename({suffix: '.min'}))
// .pipe(stripDebug())
.pipe(uglify())
.pipe(gulp.dest(destination + 'js'));
});
// Preprocess CSS
var less = require('gulp-less');
var path = require('path');
var minifyCss = require('gulp-minify-css');
gulp.task('less', function () {
return gulp.src(assets + 'css/openSUSE.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(rename({suffix: '.min'}))
.pipe(minifyCss())
.pipe(gulp.dest(destination + 'css'));
});
gulp.task('vendorCSS', ['less'], function() {
return gulp.src([assets + 'css/vendor/animate/animate.css',
assets + 'css/vendor/owl-carousel/owl.carousel.css',
assets + 'css/vendor/fontawesome/font-awesome.css'])
.pipe(concat('vendor.css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifyCss())
.pipe(gulp.dest(destination + 'css'))
});
// Images optimization
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
gulp.task('imagesCompression', function() {
return gulp.src(assets + 'images/**/*')
.pipe(cache(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true })))
.pipe(gulp.dest(destination + 'images'));
});
// Watch for changes in our custom assets
gulp.task('watch', function() {
// Watch .js files
gulp.watch(assets + 'js/*.js', ['scripts']);
gulp.watch(assets + 'js/vendor/*.js', ['scripts']);
// Watch .less files
gulp.watch(assets + 'css/*.less', ['less']);
// Watch image files
gulp.watch(assets + 'images/**/*', ['imagesCompression']);
});
// Run python server on localhost:8000
var serverCommand = 'python -m SimpleHTTPServer';
var shell = require('gulp-shell');
gulp.task('runServer', shell.task([
serverCommand
]))
// Default Task
gulp.task('default', ['scripts', 'less', 'vendorCSS', 'imagesCompression', 'watch', 'runServer']);