-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (73 loc) · 1.93 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
'use strict';
/**
* Module dependencies.
*/
var _ = require('lodash'),
assets = require('./assets'),
gulp = require('gulp'),
uglify = require('gulp-uglify'),
cssmin = require('gulp-cssmin'),
gulpLoadPlugins = require('gulp-load-plugins'),
runSequence = require('run-sequence'),
plugins = gulpLoadPlugins({
rename: {
'gulp-angular-templatecache': 'templateCache'
}
}),
path = require('path');
// CSS linting task
gulp.task('csslint', function (done) {
return gulp.src(assets.client.css)
.pipe(plugins.csslint('.csslintrc'))
.pipe(plugins.csslint.reporter())
.pipe(plugins.csslint.reporter(function (file) {
if (!file.csslint.errorCount) {
done();
}
}));
});
// JS linting task
gulp.task('jshint', function () {
var _assets = _.union(
assets.server.gulpConfig,
assets.client.js
);
return gulp.src(_assets)
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'))
.pipe(plugins.jshint.reporter('fail'));
});
// JS minifying task
gulp.task('uglify', function () {
var _assets = _.union(
assets.client.js,
assets.client.templates
);
return gulp.src(_assets)
.pipe(plugins.ngAnnotate())
// .pipe(plugins.uglify().on('error', function(err) {
// console.log(err);
// }))
.pipe(plugins.concat('application.min.js'))
.pipe(gulp.dest('./gemtool/static/dist/'));
});
// CSS minifying task
gulp.task('cssmin', function () {
return gulp.src(assets.client.css)
.pipe(plugins.cssmin().on('error', function(err) {
console.log(err);
}))
.pipe(plugins.concat('application.min.css'))
.pipe(gulp.dest('./gemtool/static/dist/'));
});
// Lint CSS and JavaScript files.
gulp.task('lint', function (done) {
//runSequence('csslint', 'jshint', done);
runSequence('csslint', 'jshint', function() {
done();
});
});
// Lint project files and minify them into two production files.
gulp.task('build', function (done) {
runSequence('lint', ['uglify', 'cssmin'], done);
});