This repository has been archived by the owner on Dec 5, 2023. It is now read-only.
forked from UWAA/uwaa-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
140 lines (110 loc) · 3.11 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
var gulp = require('gulp'),
less = require('gulp-less'),
rename = require("gulp-rename"),
watch = require('gulp-watch'),
uglify = require('gulp-uglifyjs'),
header = require('gulp-header'),
concat = require('gulp-concat'),
foreach = require('gulp-foreach'),
minifyCss = require('gulp-minify-css'),
mainBowerFiles = require('main-bower-files');
var pkg = require('./package.json');
var banner = ['/*',
' Theme Name: <%= pkg.name %>',
' Theme Uri: <%= pkg.authorUri %>',
' Description: <%= pkg.description %>',
' Author: <%= pkg.authors %>',
' Template: <%= pkg.template %>',
' Version: <%= pkg.version %>',
' */',
''].join('\n');
var mainFiles = mainBowerFiles();
// Catches errors. Will play a system tone and display your mistake.
function catchErrors(error){
console.log("\007");
console.log(error);
}
var paths = {
scripts: {
support: ['./js/support/*.js', '!./js/support/*.min.js'],
}
}
gulp.task('default', function() {
});
// Builds both dev and minified version of our JS files.
gulp.task('scripts', function() {
gulp.src([ './js/_*.js'])
.pipe(concat('uwaa.site.dev.js'))
.on('error', catchErrors)
.pipe(gulp.dest('./js'));
gulp.src([ './js/admin/_*.js'])
.pipe(concat('admin.dev.js'))
.on('error', catchErrors)
.pipe(gulp.dest('./js/admin'));
gulp.src(paths.scripts.support)
.pipe(foreach(function(stream, file){
return stream
.pipe(rename(function (path){
path.basename += ".min";
path.extname = ".js";
}))
.pipe(uglify({
mangle: true,
output: {
beautify: false
}
}))
.on('error', catchErrors)
}))
.pipe(gulp.dest('./js/support'));
gulp.src(['./js/_*.js'])
.pipe(uglify('uwaa.site.js', {
mangle: true,
output: {
beautify: false
}
}))
.on('error', catchErrors)
.pipe(gulp.dest('./js'));
gulp.src(['./js/admin/_*.js'])
.pipe(uglify('admin.js', {
mangle: true,
output: {
beautify: false
}
}))
.on('error', catchErrors)
.pipe(gulp.dest('./js/admin'));
});
gulp.task('less', function () {
gulp.src('./less/style.less')
.pipe(less())
.pipe(minifyCss())
.pipe(header(banner, { pkg : pkg } ))
.on('error', catchErrors)
.pipe(gulp.dest('./'));
gulp.src('./less/style.less')
.pipe(header(banner, { pkg : pkg } ))
.pipe(less())
.pipe(rename("style.dev.css"))
.on('error', catchErrors)
.pipe(gulp.dest('./'));
gulp.src('./less/gradpack/gradpack.less')
.pipe(less())
.pipe(minifyCss())
.on('error', catchErrors)
.pipe(gulp.dest('./'));
gulp.src('./less/admin/admin.less')
.pipe(less())
.pipe(minifyCss())
.on('error', catchErrors)
.pipe(gulp.dest('./'));
});
gulp.task('watch', function () {
gulp.watch('less/**/*.less', ['less']);
gulp.watch(['js/_*.js', 'js/admin/_*.js', 'js/support/*.js', '!js/support/*.min.js'], ['scripts']);
});
gulp.task('library', function() {
gulp.src(mainBowerFiles(/* options */), { base: 'bower_components' })
.pipe(gulp.dest('./js/libraries'));
});