This repository was archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
executable file
·133 lines (112 loc) · 2.84 KB
/
Copy pathGulpfile.js
File metadata and controls
executable file
·133 lines (112 loc) · 2.84 KB
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
var gulp = require('gulp'),
concat = require('gulp-concat-css'),
jshint = require('gulp-jshint'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
imageResize = require('gulp-image-resize'),
tinypng = require('gulp-tinypng'),
browserSync = require('browser-sync').create();
/*
* To use the gulp-image-resize, it needs of some dependencies:
* https://www.npmjs.com/package/gulp-image-resize
*
* Or, install:
*
* Ubuntu:
* apt-get install imagemagick
* apt-get install graphicsmagick
*
* Mac:
* brew install imagemagick
* brew install graphicsmagick
*
* Windows & others:
* http://www.imagemagick.org/script/binary-releases.php
* */
var tinypngToken = 'hHrU0V0DGG3tNna6R1sqNNOqqU-x1S4u';
var dist = {
location: 'dist/'
};
var images = {
content: '*.*',
location: 'img/'
};
images.largePhotos = {
content: '*.*',
location: images.location + 'largePhotos/'
};
var cssfiles = 'css/*.css',
imgfiles = 'img/*',
jsfiles = 'js/*.js';
imgfiles = 'img/*';
gulp.task('oai', function() {
gulp.src(cssfiles)
.pipe(concat('oai.css'))
.pipe(gulp.dest('dist/css'));
gulp.src('dist/css/oai.css')
.pipe(minifycss())
.pipe(rename({
extname: '.min.css'
}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('minifyCss', function () {
gulp.src('dist/css/oai.css')
.pipe(minifycss())
.pipe(rename({
extname: '.min.css'
}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('js', function() {
gulp.src(jsfiles)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(gulp.dest('dist/js'));
gulp.src(['dist/js/dist.js'])
.pipe(rename({
extname: '.min.js'
}))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('resizeLargePhotos', function () {
gulp.src(images.largePhotos.location + images.largePhotos.content)
.pipe(imageResize({
height : 960,
upscale : false
}))
.pipe(gulp.dest(dist.location + images.largePhotos.location));
});
gulp.task('tinyImages', function () {
gulp.src(images.location + 'src/' + images.content)
.pipe(tinypng(tinypngToken))
.pipe(gulp.dest(images.location));
});
gulp.task('tinyLargePhotos', function () {
gulp.src(images.largePhotos.location + images.largePhotos.content)
.pipe(tinypng(tinypngToken))
.pipe(gulp.dest(images.largePhotos.location));
});
gulp.task('tiny', ['tinyImages', 'tinyLargePhotos']);
gulp.task('watch', function () {
gulp.watch(cssfiles, ['oai']);
});
gulp.task('oai-watch', ['oai'], function () {
browserSync.reload();
});
// Watch scss AND html files, doing different things with each.
gulp.task('serve', ['oai'], function () {
// Serve files from the root of this project
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(cssfiles, ['oai-watch']);
gulp.watch("*.html").on("change", browserSync.reload);
});
gulp.task('default', ['serve']);