-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
88 lines (76 loc) · 2.63 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
var es = require('event-stream'),
gulp = require('gulp'),
gutil = require('gulp-util'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
plugins = require('gulp-load-plugins')();
function errorHandler(error) {
// console.log(error);
gutil.log(gutil.colors.red(error.toString()));
this.emit('end');
}
function scripts(src, dest) {
return gulp.src(src)
.pipe(plugins.concat(dest));
}
function sass(src) {
return gulp.src(src)
.pipe(plugins.sass().on('error', plugins.sass.logError));
}
var isProduction = true,
vendorStyles = [
'node_modules/purecss/build/pure.css',
'node_modules/open-iconic/font/css/open-iconic.css'
],
siteStyles = [
'auth/assets/styles/**/*.scss'
],
ieScripts = [
'node_modules/es5-shim/es5-shim.js',
'node_modules/html5shiv/html5shiv.js'
],
siteScripts = [
'node_modules/zepto/src/zepto.js',
'node_modules/zepto/src/ajax.js',
'node_modules/zepto/src/callbacks.js',
'node_modules/zepto/src/deferred.js',
'node_modules/zepto/src/event.js',
'node_modules/marked/lib/marked.js',
'auth/assets/scripts/**/*.js',
];
if(gutil.env.dev === true) {
isProduction = false;
}
gulp.task('styles', function() {
return es.concat(gulp.src(vendorStyles), sass(siteStyles))
.pipe(plugins.concat('screen.min.css'))
.pipe(plugins.autoprefixer('last 2 versions', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4', 'Firefox >= 4'))
// .pipe(isProduction ? plugins.combineMediaQueries({ log: true }) : gutil.noop())
.pipe(isProduction ? plugins.cssnano() : gutil.noop())
.pipe(plugins.size())
.pipe(gulp.dest('./auth/static/styles'))
.pipe(browserSync.stream());
});
gulp.task('scripts', function() {
return es.concat(
scripts(ieScripts, 'ie.min.js'),
scripts(siteScripts, 'site.min.js'))
.pipe(isProduction ? plugins.uglify() : gutil.noop()).on('error', errorHandler)
.pipe(plugins.size())
.pipe(gulp.dest('./auth/static/scripts'));
});
gulp.task('fonts', function() {
return gulp.src([
'node_modules/open-iconic/font/fonts/**/*'
]).pipe(gulp.dest('./auth/static/fonts'));
});
gulp.task('build', [ 'styles', 'scripts', 'fonts' ]);
gulp.task('serve', [ 'build' ], function() {
browserSync({
proxy: 'localhost:5000'
});
gulp.watch(vendorStyles.concat(siteStyles), [ 'styles' ]);
gulp.watch(ieScripts.concat(siteScripts), [ 'scripts' ]);
gulp.watch('auth/templates/**/*.html', reload);
});
gulp.task('default', [ 'build' ]);