-
Notifications
You must be signed in to change notification settings - Fork 50
/
gulpfile.js
132 lines (112 loc) · 3.2 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
/* global require */
var gulp = require('gulp'),
sass = require('gulp-sass'),
connect = require('gulp-connect'),
clean = require('del'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
addStream = require('add-stream'),
templateCache = require('gulp-angular-templatecache'),
replaceName = require('gulp-html-replace'),
mainBowerFiles = require('main-bower-files');
var appConfig = {
app: 'app',
dist: 'dist',
src : 'src'
};
gulp.task('connect', function () {
connect.server({
root: 'dist',
port: 8080,
livereload: true,
middleware: function (connect) {
return [connect().use('/bower_components', connect.static('bower_components'))];
}
});
});
gulp.task('replaceName', function() {
gulp.src('app/index.html')
.pipe(gulp.dest('dist/'));
});
gulp.task('html', function () {
gulp.src('app/**/*.html')
.pipe(replaceName({
'css': ['styles/vendor.min.css', 'styles/picker.min.css'],
'js': ['scripts/vendor.min.js', 'scripts/script.min.js']
}))
.pipe(gulp.dest('dist/'))
.pipe(connect.reload())
});
gulp.task('copyjs', function () {
gulp.src([
'app/scripts/app.js',
'app/scripts/**/*.js',
'app/picker/**/*.js',
'app/menu/**/*.js',
])
//.pipe(order())
.pipe(concat('script.min.js'))
.pipe(gulp.dest('dist/scripts/'))
.pipe(connect.reload());
});
gulp.task('styles', function() {
gulp.src('app/styles/*.scss')
.pipe(sass())
.pipe(concat('picker.min.css'))
.pipe(gulp.dest('dist/styles/'))
.pipe(connect.reload());
});
// build vendor js and styles
gulp.task('vendorJs', function(){
gulp.src(mainBowerFiles('**/*.js'))
// .pipe(uglify())
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest('dist/scripts/'));
});
gulp.task('vendorCss', function(){
gulp.src(mainBowerFiles('**/*.css'))
.pipe(concat('vendor.min.css'))
.pipe(gulp.dest('dist/styles/'));
});
// watch task
gulp.task('watch', function() {
gulp.watch('app/**/*.html', ['html']);
gulp.watch('app/**/*.js', ['copyjs']);
gulp.watch('app/styles/*.scss', ['styles']);
});
// clean task
gulp.task('clean', function() {
return clean(['dist/*']);
});
/*
buid task for distribution
*/
function prepareTemplates() {
return gulp.src('app/picker/*.html')
.pipe(templateCache({
module:'smDateTimeRangePicker',
transformUrl: function(url) {
return 'picker/'+url;
}
}));
}
gulp.task('stylePicker', function() {
gulp.src('app/styles/date_picker.scss')
.pipe(sass())
.pipe(rename('picker.css'))
.pipe(gulp.dest('src/'));
});
gulp.task('pickerJs', function () {
// solution via https://github.com/auth0/angular-storage
gulp.src(['app/picker/js/picker.prefix', 'app/picker/js/*.js', 'app/picker/js/picker.suffix'])
.pipe(addStream.obj(prepareTemplates()))
.pipe(concat('picker.js'))
.pipe(gulp.dest('src/'));
});
gulp.task('cleanSrc', function() {
return clean(['src/']);
});
//Watch task
gulp.task('default', ['clean', 'html', 'vendorCss', 'vendorJs', 'styles', 'copyjs', 'watch', 'connect']);
gulp.task('serve', ['default']);
gulp.task('build', ['cleanSrc', 'pickerJs', 'stylePicker']);