-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
130 lines (121 loc) · 3.66 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
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')({
'rename' : {
'gulp-util' : 'gutil'
}
});
// A single variable to hold all the paths
var paths = {
'admin_scripts' : ['./assets/javascript/admin/*.js', '!./assets/javascript/admin/*.min.js', '!./**/build.js'],
'front_scripts' : ['./assets/javascript/front/*.js', '!./assets/javascript/front/*.min.js', '!./**/build.js'],
'admin_styles' : ['./assets/styles/admin/**/*.scss'],
'front_styles' : ['./assets/styles/front/**/*.scss']
};
// Combine and minify scripts
gulp.task('front_scripts', function() {
'use strict';
return gulp.src(paths.front_scripts)
.pipe(plugins.plumber(
function(err) {
console.log( err );
plugins.gutil.log(plugins.gutil.colors.red( 'Error on ' + err.plugin + '\n' + err.message ) );
plugins.gutil.beep();
this.emit('end');
}
))
.pipe(plugins.changed('./dist/javascript'))
.pipe(plugins.concat('script.js'))
.pipe(gulp.dest('./dist/javascript'))
.pipe(plugins.notify('<%= file.relative %> updated'))
.pipe(plugins.rename({
'suffix' : '.min'
}))
.pipe(plugins.uglify())
.pipe(gulp.dest('./dist/javascript'));
});
// Combine and minify admin scripts
gulp.task('admin_scripts', function() {
'use strict';
return gulp.src(paths.admin_scripts)
.pipe(plugins.plumber(
function(err) {
console.log( err );
plugins.gutil.log(plugins.gutil.colors.red( 'Error on ' + err.plugin + '\n' + err.message ) );
plugins.gutil.beep();
this.emit('end');
}
))
.pipe(plugins.changed('./dist/javascript/admin'))
.pipe(plugins.concat('admin.js'))
.pipe(gulp.dest('./dist/javascript/admin'))
.pipe(plugins.notify('<%= file.relative %> updated'))
.pipe(plugins.rename({
'suffix' : '.min'
}))
.pipe(plugins.uglify())
.pipe(gulp.dest('./dist/javascript/admin'));
});
// Compile and minify scss files
gulp.task('admin_styles', function() {
'use strict';
return gulp.src(paths.admin_styles)
.pipe(plugins.plumber(
function(err) {
plugins.gutil.log(plugins.gutil.colors.red( 'Error on ' + err.plugin + '\n' + err.messageFormatted ) );
plugins.gutil.beep();
this.emit('end');
}
))
.pipe(plugins.sass())
.pipe(plugins.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('./dist/styles/admin'))
.pipe(plugins.rename({
'suffix' : '.min'
}))
.pipe(plugins.cleanCss())
.pipe(gulp.dest('./dist/styles/admin'))
.pipe(plugins.notify({
'message' : 'Styles updated',
'onLast' : true
}));
});
gulp.task('front_styles', function() {
'use strict';
return gulp.src(paths.front_styles)
.pipe(plugins.plumber(
function(err) {
plugins.gutil.log(plugins.gutil.colors.red( 'Error on ' + err.plugin + '\n' + err.messageFormatted ) );
plugins.gutil.beep();
this.emit('end');
}
))
.pipe(plugins.sass())
.pipe(plugins.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('./dist/styles/front'))
.pipe(plugins.rename({
'suffix' : '.min'
}))
.pipe(plugins.cleanCss())
.pipe(gulp.dest('./dist/styles/front'))
.pipe(plugins.notify({
'message' : 'Styles updated',
'onLast' : true
}));
});
// Live update these files
gulp.task('watch', function() {
'use strict';
gulp.watch(paths.admin_scripts, ['admin_scripts']);
gulp.watch(paths.front_scripts, ['front_scripts']);
gulp.watch(paths.admin_styles, ['admin_styles']);
gulp.watch(paths.front_styles, ['front_styles']);
plugins.livereload.listen();
gulp.watch(['./dist/**/*']).on('change', plugins.livereload.changed);
});
gulp.task('default', [
'admin_scripts',
'front_scripts',
'admin_styles',
'front_styles',
'watch'
]);