-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
137 lines (131 loc) · 5.54 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*jslint node: true */
(function() {
'use strict';
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var livereload = require('gulp-livereload');
var del = require('del');
var templateCache = require('gulp-angular-templatecache');
var child = require('child_process');
var fs = require('fs');
gulp.task('server', function() {
var server = child.spawn('node', ['./bin/www']);
var log = fs.createWriteStream('server.log', {
flags: 'a'
});
server.stdout.pipe(log);
server.stderr.pipe(log);
});
gulp.task('clean', function() {
return del(['public']);
});
gulp.task('scripts', function() {
return gulp.src([
'!solarwatt/**/*.spec.js',
'solarwatt/auth/auth.module.js',
'solarwatt/auth/auth.factory.js',
'solarwatt/**/*.module.js',
'solarwatt/**/*.controller.js',
'solarwatt/**/*.js',
'solarwatt/app.js'
])
.pipe(concat('main.js'))
.pipe(gulp.dest('public/javascripts'))
.pipe(rename({
suffix: '.min'
})).pipe(uglify())
.pipe(gulp.dest('public/javascripts'));
});
gulp.task('template_cache', function() {
return gulp.src('solarwatt/**/*.html')
.pipe(templateCache({
module: 'solarwatt.templates',
standalone: true
}))
.pipe(gulp.dest('public/javascripts'));
});
gulp.task('pages', function() {
return gulp.src('solarwatt/index.html')
.pipe(gulp.dest('public'));
});
gulp.task('images', function() {
return gulp.src('images/**')
.pipe(gulp.dest('public/images'));
});
gulp.task('favicon', function() {
return gulp.src('favicon.ico')
.pipe(gulp.dest('public'));
});
gulp.task('select2_images', function() {
return gulp.src([
'bower_components/select2/select2.png',
'bower_components/select2/select2-spinner.gif',
])
.pipe(gulp.dest('public/stylesheets'));
});
gulp.task('vendor_images', ['favicon', 'select2_images']);
gulp.task('vendor_js', function() {
return gulp.src(
[
'bower_components/jquery/dist/jquery.js',
'bower_components/select2/select2.js',
'bower_components/angular/angular.js',
'bower_components/angular-ui-router/release/angular-ui-router.js',
'bower_components/lodash/lodash.js',
'bower_components/restangular/dist/restangular.js',
'bower_components/angular-loading-bar/build/loading-bar.js',
'bower_components/angular-bootstrap/ui-bootstrap.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/angular-carousel/dist/angular-carousel.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-ui-select2/src/select2.js',
'bower_components/moment/moment.js',
'bower_components/angular-moment/angular-moment.js',
'bower_components/angular-timeago/src/timeAgo.js',
'bower_components/ngtoast/dist/ngToast.js'
])
.pipe(concat('vendor.js'))
.pipe(gulp.dest('public/javascripts'));
});
gulp.task('vendor_css', function() {
return gulp.src(
[
'bower_components/bootstrap/dist/css/bootstrap.css',
'bower_components/angular-loading-bar/build/loading-bar.css',
'bower_components/angular-bootstrap/ui-bootstrap-csp.css',
'bower_components/angular-carousel/dist/angular-carousel.css',
'bower_components/select2/select2.css',
'bower_components/ngtoast/dist/ngToast.css',
'bower_components/ngtoast/dist/ngToast-animations.css'
])
.pipe(concat('vendor.css'))
.pipe(gulp.dest('public/stylesheets'));
});
gulp.task('vendor_css_map', function() {
return gulp.src(
[
'bower_components/bootstrap/dist/css/bootstrap.css.map',
'bower_components/angular-carousel/dist/angular-carousel.css.map'
])
.pipe(gulp.dest('public/stylesheets'));
});
gulp.task('vendor_components', ['vendor_js', 'vendor_css', 'vendor_css_map', 'vendor_images']);
gulp.task('watch', function() {
// Watch .js files
gulp.watch('solarwatt/**/*.js', ['scripts']);
gulp.watch('solarwatt/**/*.html', ['template_cache']);
gulp.watch('solarwatt/index.html', ['pages']);
gulp.watch('routes/**', ['server']).on('change', livereload.changed);
gulp.watch('app.js', ['server']).on('change', livereload.changed);
// Create LiveReload server
livereload.listen();
// Watch any files in dist/, reload on change
gulp.watch(['public/**']).on('change', livereload.changed);
gulp.watch(['views/**']).on('change', livereload.changed);
});
gulp.task('build', ['vendor_components', 'scripts', 'template_cache', 'pages', 'images']);
gulp.task('default', ['watch', 'build', 'server']);
return gulp;
})();