This repository was archived by the owner on Oct 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
145 lines (119 loc) · 3.83 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
// Package
var fs = require('fs');
var pkg = JSON.parse(fs.readFileSync('./package.json'));
// Gulp
var gulp = require('gulp');
// Plugins
var autoprefixer = require('gulp-autoprefixer');
var cleancss = require('gulp-clean-css');
var concat = require('gulp-concat');
var del = require('del');
var favicons = require('gulp-favicons');
var fontAwesome = require('node-font-awesome');
var imagemin = require('gulp-imagemin');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var watch = require('gulp-watch');
// Build
gulp.task('build:css', function(){
return gulp.src(["./node_modules/bootstrap/dist/css/bootstrap.min.css", pkg.settings.src.css])
.pipe(sourcemaps.init())
.pipe(concat(pkg.settings.filenames.css))
.pipe(sass({
includePaths: [fontAwesome.scssPath]
}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cleancss())
.pipe(sourcemaps.write())
.pipe(gulp.dest(pkg.settings.out.css));
});
gulp.task('build:js', function(){
return gulp.src(["./node_modules/jquery/dist/jquery.js",
"./node_modules/tether/dist/js/tether.js",
"./node_modules/bootstrap/dist/js/bootstrap.js",
pkg.settings.src.js])
.pipe(sourcemaps.init())
.pipe(concat(pkg.settings.filenames.js))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(pkg.settings.out.js));
});
gulp.task('build:images', function(){
return gulp.src(pkg.settings.src.images)
.pipe(imagemin())
.pipe(gulp.dest(pkg.settings.out.images));
});
gulp.task('build:templates', function(){
return gulp.src(pkg.settings.src.templates)
.pipe(gulp.dest(pkg.settings.out.templates));
});
gulp.task('build:fonts', function(){
return gulp.src([fontAwesome.fonts, pkg.settings.src.fonts])
.pipe(gulp.dest(pkg.settings.out.fonts));
});
gulp.task('build:favicon', function(){
return gulp.src(pkg.settings.src.favicon)
.pipe(favicons(pkg.settings.favicon))
.on('error', util.log)
.pipe(gulp.dest(pkg.settings.out.favicon));
});
// gulp.task('build', ['build:css', 'build:js', 'build:images', 'build:templates', 'build:fonts', 'build:favicon'], function(){});
gulp.task('build', ['build:css', 'build:js', 'build:images', 'build:templates', 'build:fonts'], function(){});
// Clean
gulp.task('clean:css', function() {
return del.sync(pkg.settings.out.css);
});
gulp.task('clean:templates', function(){
return del.sync(pkg.settings.out.templates);
});
gulp.task('clean:js', function(){
return del.sync(pkg.settings.out.js);
});
gulp.task('clean:images', function(){
return del.sync(pkg.settings.out.images);
});
gulp.task('clean:fonts', function(){
return del.sync(pkg.settings.out.fonts);
});
gulp.task('clean', ['clean:css', 'clean:templates', 'clean:js', 'clean:images', 'clean:fonts'], function(){});
// watch
gulp.task('watch', function(){
runSequence('clean', 'build');
// CSS
watch([
pkg.settings.src.css
], (events) => {
runSequence('clean:css', 'build:css');
});
// JS
watch([
pkg.settings.src.js
], (events) => {
runSequence('clean:js', 'build:js');
});
// Images
watch([
pkg.settings.src.images
], (events) => {
runSequence('clean:images', 'build:images');
});
// Templates
watch([
pkg.settings.src.templates
], (events) => {
runSequence('clean:templates', 'build:templates');
});
// Fonts
watch([
pkg.settings.src.fonts
], (events) => {
runSequence('clean:fonts', 'build:fonts');
});
});
gulp.task('default', ['watch']);