forked from Ascarbek/suggestbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (101 loc) · 3.72 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
/**
* Created by Ascarbek on 01.12.2015.
*/
var gulp = require('gulp'),
del = require('del'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
nano = require('gulp-cssnano'),
inject = require('gulp-inject'),
es = require('event-stream'),
series = require('stream-series'),
ngTemplates = require('gulp-ng-templates'),
replace = require('gulp-replace'),
_ = require('underscore');
gulp.task('clean', function(){
return del(['dist']);
});
/*
* Development
* */
gulp.task('build-dev', ['clean'], function(){
return gulp.src('server/env.config.json')
.pipe(replace('dist', 'src'))
.pipe(gulp.dest('server'));
});
gulp.task('inject-dev', ['build-dev'], function(){
return gulp.src('src/demo.html')
.pipe(inject(series(
gulp.src(['src/vendor/angular/angular.min.js'], {read : false}),
gulp.src(['src/vendor/**/*min.js', '!src/vendor/angular/angular.min.js'], {read : false}),
gulp.src(['src/js/module.js'], {read: false}),
gulp.src(['src/js/*.js', '!src/js/module.js'], {read: false}),
gulp.src(['src/demo/demo.js'], {read: false})
), {relative : true, ignorePath: 'src'}))
.pipe(inject(
gulp.src([
'src/vendor/**/*min.css',
'src/css/suggest.box.css',
'src/demo/demo.css'
], {read: false}), {relative: true, ignorePath: 'src'}
))
.pipe(gulp.dest('src'));
});
/*
* Production
* */
gulp.task('copy-prod', ['clean'], function(){
return es.merge(
gulp.src(['src/vendor/**/*min.js', 'src/vendor/**/*min.css'])
.pipe(gulp.dest('dist/vendor')),
gulp.src(['src/vendor/font-awesome/fonts/*'])
.pipe(gulp.dest('dist/vendor/font-awesome/fonts'))
);
});
gulp.task('build-prod', ['copy-prod'], function(){
return es.merge(
gulp.src('server/env.config.json')
.pipe(replace('src', 'dist'))
.pipe(gulp.dest('server')),
es.merge(
series(
gulp.src(['src/js/module.js']),
gulp.src(['src/js/*.js', '!src/js/module.js'])
).pipe(concat('suggest.box.js'))
.pipe(gulp.dest('dist')),
series(
gulp.src(['src/js/module.js']),
gulp.src(['src/js/*.js', '!src/js/module.js'])
).pipe(concat('suggest.box.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'))
),es.merge(
gulp.src('src/css/suggest.box.css')
.pipe(gulp.dest('dist')),
gulp.src('src/demo/demo.css')
.pipe(gulp.dest('dist')),
gulp.src('src/css/suggest.box.css')
.pipe(concat('suggest.box.min.css'))
.pipe(nano())
.pipe(gulp.dest('dist'))
),
gulp.src('src/demo/demo.js')
.pipe(gulp.dest('dist'))
);
});
gulp.task('inject-prod', ['build-prod'], function(){
return gulp.src('src/demo.html')
.pipe(inject(series(
gulp.src(['dist/vendor/angular/angular.min.js'], {read : false}),
gulp.src(['dist/vendor/**/*min.js', '!dist/vendor/angular/angular.min.js'], {read : false}),
gulp.src(['dist/suggest.box.js'], {read: false}),
gulp.src(['dist/demo.js'], {read: false})
), {relative : false, ignorePath: 'dist'}))
.pipe(inject(series(
gulp.src(['dist/vendor/**/*min.css'], {read: false}),
gulp.src(['dist/suggest.box.css'], {read: false}),
gulp.src(['dist/demo.css'], {read: false})
), {relative: false, ignorePath: 'dist'}))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['inject-prod']);