-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (85 loc) · 3.27 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
/// <binding BeforeBuild='sass, js' Clean='clean' />
var gulp = require('gulp'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
uglifycss = require('gulp-uglifycss'),
sourcemaps = require('gulp-sourcemaps'),
ngAnnotate = require('gulp-ng-annotate'),
del = require('del'),
bowerFiles = require('bower-files')({ json: './client/bower.json' }),
gulpFilter = require('gulp-filter'),
tar = require('gulp-tar'),
gzip = require('gulp-gzip'),
autoprefixer = require('gulp-autoprefixer');
gulp.task('default', ['sass'], function(){
});
gulp.task('js', function(){
return gulp.src(['./client/js/app.js', './client/js/*.js'])
.pipe(concat('app.min.js'))
.pipe(ngAnnotate())
.pipe(uglify({compress: {hoist_funs: false, hoist_vars: false}}))
.pipe(gulp.dest('./client/'))
});
gulp.task('sass', function(){
return gulp.src('./client/sass/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(uglifycss({
"maxLineLength": 100
}))
.pipe(gulp.dest('./client/css'));
});
// Create a ready-to-install "release" directory
gulp.task('release', ['clean', 'sass', 'js'], function(){
// package.json
gulp.src('./package.json')
.pipe(gulp.dest('./release/'));
// main.js
gulp.src('./main.js')
.pipe(gulp.dest('./release/'));
// Server files
gulp.src(['./server/**/*', '!./server/data/**/*', '!./server/*.log*'])
.pipe(gulp.dest('./release/server/'));
// Config
gulp.src(['./config/default.json', './config/production.json'])
.pipe(gulp.dest('./release/config/'));
// CSS files
gulp.src(['./client/**/*', '!./client/js/', '!./client/js/**', '!./client/sass/', '!./client/sass/**', '!./client/update-locale-files.js'])
.pipe(gulp.dest('./release/client/'));
// Windows service
gulp.src('./win-service.js')
.pipe(gulp.dest('./release/'));
});
gulp.task('watch', function(){
gulp.watch("./client/sass/*.scss", ['sass'])
.on('change', function(event){
console.log('File ' + event.path + ' has been modified');
});
gulp.watch("./client/js/*.js", ['js'])
.on('change', function(event){
console.log('File ' + event.path + ' has been modified');
});
});
gulp.task('tar', function(){
gulp.src('./release/**/*')
.pipe(tar('release.tar'))
.pipe(gzip())
.pipe(gulp.dest('.'));
})
gulp.task('clean', function(){
return del(['./release', './release.tar.gz']);
});
gulp.task('web-assets', function(){
gulp.src([
'./node_modules/angular/angular.js',
'./node_modules/angular-animate/angular-animate.min.js',
'./node_modules/angular-touch/angular-touch.min.js',
'./node_modules/angular-translate/dist/angular-translate.min.js',
'./node_modules/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js',
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./node_modules/bootstrap/dist/js/bootstrap.min.js',
'./node_modules/jquery/dist/jquery.min.js'
])
.pipe(gulp.dest('./client/vendor'));
});