-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (95 loc) · 3 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
/**
* This file is subject to the terms and conditions defined in
* file 'LICENSE' or 'LICENSE.txt', which is part of this source code package.
*/
var gulp = require('gulp')
, plugins = require('gulp-load-plugins')()
, pkg = require('./package.json')
, fs = require('fs')
, VIEWS = [
'./src/views/main.html',
'./src/views/tile-facebook.html',
'./src/views/tile-instagram.html',
'./src/views/tile-twitter.html'
]
, FILES = [
'./src/app.js',
'./src/views.js',
'./src/controllers/default.js',
'./src/directives/isotope.js',
'./src/directives/isotope-tile.js',
'./src/filters/emoji.js',
'./src/services/infinity.js',
'./src/services/isotope.js',
'./src/services/backend.js'
]
, BANNER = './src/header.txt'
, MAIN = 'socialhub.js';
gulp.task( 'jscodesnifer', function() {
return gulp.src( FILES )
.pipe( plugins.jscodesniffer(
{ standard: 'Idiomatic', reporters: [ 'default', 'failer' ] }
) );
});
gulp.task( 'lint', ['jscodesnifer'], function() {
return gulp.src( FILES )
.pipe( plugins.jshint() )
.pipe( plugins.jshint.reporter('jshint-stylish') );
} );
gulp.task( 'clean:tmp', function() {
return gulp.src( '.tmp', { read: false } )
.pipe( plugins.clean() );
} );
gulp.task( 'clean:views', ['copy'], function() {
return gulp.src( './src/views.js', { read: false } )
.pipe( plugins.clean() );
} );
gulp.task( 'minify:html', [ 'clean:tmp', 'lint' ], function() {
return gulp.src( VIEWS )
.pipe( plugins.minifyHtml({
empty: true,
quotes: true
}) )
.pipe( gulp.dest('.tmp/views') );
} );
gulp.task( 'html2js', ['minify:html'], function() {
return gulp.src( '.tmp/views/*.html' )
.pipe( plugins.ngHtml2js({
moduleName: pkg.name.replace( '-', '.' ),
declareModule: false,
prefix: 'views/%s/'.replace( '%s', pkg.name.split('-')[1] )
}) )
.pipe( gulp.dest('.tmp/views') );
} );
gulp.task( 'build:html', ['html2js'], function() {
return gulp.src('.tmp/views/*.js')
.pipe( plugins.concat( 'views.js' ) )
.pipe( gulp.dest('src') );
} );
gulp.task( 'build', ['build:html'], function() {
return gulp.src( FILES )
.pipe( plugins.concat( MAIN ) )
.pipe( plugins.ngAnnotate() )
.pipe( plugins.header( fs.readFileSync( BANNER, 'utf8' ), { pkg : pkg } ) )
.pipe( gulp.dest('.') );
} );
gulp.task( 'minify', ['build'], function() {
return gulp.src( MAIN )
.pipe( plugins.plumber() )
.pipe( plugins.uglify() )
.pipe( plugins.rename({ extname: '.min.js' }) )
.pipe( plugins.header( fs.readFileSync( BANNER, 'utf8' ), { pkg : pkg } ) )
.pipe( gulp.dest('.') );
} );
gulp.task( 'copy', [ 'minify' ], function() {
return gulp.src([ MAIN, MAIN.replace('.js', '.min.js') ])
.pipe( gulp.dest('examples/client/vendor') );
} );
gulp.task( 'complexity', function() {
return gulp.src( MAIN )
.pipe( plugins.complexity() );
} );
gulp.task( 'watch', function() {
gulp.watch( FILES, [ 'complexity', 'clean:views' ] );
} );
gulp.task( 'default', ['clean:views'] );