-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
117 lines (103 loc) · 3.24 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
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
var cleanCSS = require('gulp-clean-css');
var concatCss = require('gulp-concat-css');
var minifyCSS = require('gulp-minify-css');
// Lint Task
gulp.task('lint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Minify JS
gulp.task('scripts', function() {
return gulp.src('js/src/*.js')
.pipe(rename(function(path) {
path.basename += '.min';
}))
.pipe(uglify())
.pipe(gulp.dest('js/dist'));
});
gulp.task('live-to-admin-scripts', function() {
return gulp.src('js/src/*.js')
.pipe(rename(function(path) {
path.basename += '.admin.min';
}))
.pipe(uglify())
.pipe(gulp.dest('admin/js/dist'));
});
// Minify Admin JS
gulp.task('admin-scripts', function() {
return gulp.src('admin/js/src/*.js')
.pipe(rename(function(path) {
path.basename += '.min';
}))
.pipe(uglify())
.pipe(gulp.dest('admin/js/dist'));
});
// Combine CSS
gulp.task('combine-css', function () {
return gulp.src(['css/src/bootstrap.css','css/src/style.css'])
.pipe(minifyCSS())
.pipe(concat('bootstyle.min.css'))
.pipe(gulp.dest('css/dist/'));
});
gulp.task('live-to-admin-combine-css', function () {
return gulp.src(['css/src/bootstrap.css','css/src/style.css'])
.pipe(minifyCSS())
.pipe(concat('bootstyle.admin.min.css'))
.pipe(gulp.dest('admin/css/dist/'));
});
// Combine Admin CSS
gulp.task('combine-admin-css', function () {
return gulp.src(['admin/css/src/bootstrap.css','admin/css/src/style.css'])
.pipe(minifyCSS())
.pipe(concat('bootstyle.min.css'))
.pipe(gulp.dest('admin/css/dist/'));
});
// Minify CSS
gulp.task('minify-css', function() {
return gulp.src('css/src/*.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(rename(function(path) {
path.basename += '.min';
}))
.pipe(gulp.dest('css/dist'));
});
gulp.task('live-to-admin-minify-css', function() {
return gulp.src('css/src/*.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(rename(function(path) {
path.basename += '.admin.min';
}))
.pipe(gulp.dest('admin/css/dist'));
});
// Minify Admin CSS
gulp.task('minify-admin-css', function() {
return gulp.src('admin/css/src/*.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(rename(function(path) {
path.basename += '.min';
}))
.pipe(gulp.dest('admin/css/dist'));
});
gulp.task('minify-image', function() {
return gulp.src('images/*')
.pipe(imagemin())
.pipe(gulp.dest('images/'))
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('js/src/*.js', ['lint', 'scripts']);
gulp.watch('css/src/*.css', ['minify-css']);
});
// Default Task
gulp.task('default', ['lint', 'scripts', 'watch', 'minify-css', 'minify-image', 'combine-css','combine-admin-css', 'minify-admin-css', 'admin-scripts']);
gulp.task('admin', ['combine-admin-css', 'minify-admin-css', 'admin-scripts']);
gulp.task('live-to-admin', ['live-to-admin-combine-css', 'live-to-admin-minify-css', 'live-to-admin-scripts']);