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