-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (79 loc) · 2.33 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
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var concatCss = require('gulp-concat-css');
var csso = require('gulp-csso');
var minifyHtml = require('gulp-minify-html');
var ngTemplateCache = require('gulp-angular-templatecache');
var defineModule = require('gulp-define-module');
gulp.on('error', function(err){
console.log(err);
});
gulp.task('compile-templates', function() {
return gulp.src('./src/templates/**/*.html')
.pipe(minifyHtml({ empty: true, spare: true, quotes: true }))
.pipe(ngTemplateCache({ module: 'formula', root: 'formula/' }))
.pipe(gulp.dest('./src/templates/'));
});
gulp.task('compile-js', ['compile-templates'], function() {
return gulp.src(['./src/**/*.js'])
.pipe(concat('formula.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('minify-js', ['compile-templates'], function(cb) {
return gulp.src(['./src/**/*.js'])
.pipe(concat('formula.min.js'))
.pipe(uglify().on('error', function(err){
console.log(err);
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('validate-js', ['compile-templates'], function() {
return gulp.src(['./src/**/*.js'])
.pipe(jshint({
globals: {angular: true}
}))
.pipe(jshint.reporter('default'));
});
gulp.task('compile-commonjs', ['compile-templates'], function () {
return gulp.src(['src/**/*.js'])
.pipe(concat('formula.commonjs.js'))
.pipe(defineModule('commonjs', { require: {
angular: 'angular',
tv4: 'tv4'
}}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('compile-css', function() {
return gulp.src('./src/*.css')
.pipe(concatCss('formula.css'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('minify-css', function() {
return gulp.src('./src/*.css')
.pipe(concatCss('formula.min.css'))
.pipe(csso())
.pipe(gulp.dest('./dist/'));
});
gulp.task('validate', [
'validate-js'
]);
gulp.task('default', [
'validate',
'compile-js',
'minify-js',
'compile-commonjs',
'compile-css',
'minify-css'
]);
gulp.task('watch', ['watch-js', 'watch-css'], function() {
gulp.watch('./src/**', ['default']);
});
gulp.task('watch-js', ['default'], function() {
gulp.watch(['./src/**/*.js'], ['validate', 'compile-js', 'minify-js', 'compile-commonjs']);
});
gulp.task('watch-css', ['default'], function() {
gulp.watch('./src/*.css', ['compile-css', 'minify-css']);
});