-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
167 lines (137 loc) · 4.42 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var ngmin = require('gulp-ngmin');
var jshint = require('gulp-jshint');
var ngTemplates = require('gulp-ng-templates');
var header = require('gulp-header');
var webserver = require('gulp-webserver');
var gulpLoadPlugins = require('gulp-load-plugins');
var plugins = gulpLoadPlugins();
var htmlmin = require('gulp-htmlmin');
var autoprefixer = require('gulp-autoprefixer');
var pkg = require('./package.json');
var paths = {
sass: ['./src/**/*.scss'],
js : ['./src/**/*.js'],
html : ['./src/**/*.html']
};
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = dd+'/'+mm+'/'+yyyy;
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @author : pezouvanis sotiris ',
' * Copyright (c) '+today,
' */',
''].join('\n');
gulp.task('webserver', function() {
return gulp.src('./public_html')
.pipe(plugins.webserver({
host:'192.168.0.100',
livereload: true,
directoryListing: false,
open: true ,
fallback: 'index.html'
}));
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.html, ['html']);
gulp.watch(paths.js, ['scripts']);
});
gulp.task('sass',function() {
gutil.log("Building css files...");
return gulp.src(paths.sass)
.pipe(concat('angular-slider'))
.pipe(sass())
.pipe(autoprefixer({
browsers: ['> 0%', 'last 2 versions' ],
cascade: false
}))
.pipe(gulp.dest('./dist/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename('sotos.angular-slider.min.css' ))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist/css/'))
.pipe(gulp.dest('./public_html/static/css/'));
});
gulp.task('scripts', function() {
return gulp.src(['./src/js/main.js',
'./src/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter(function(data){
gutil.beep();
}))
.pipe(concat(pkg.name+'.js'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist/js/'))
.pipe(gulp.dest('./public_html/static/js/'))
.pipe(ngmin({dynamic: false}))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist/js/'))
.pipe(gulp.dest('./public_html/static/js/'));
});
//min vendor javascript files
// not use this time
gulp.task('vendor', function() {
return gulp.src(['./bower_components/angular/angular.js',
'./bower_components/angular-animate/angular-animate.js',
'./vendor/*.js'])
.pipe(concat('vendor.js'))
.pipe(gulp.dest('./public_html/static/js'))
.pipe(ngmin({dynamic: false}))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./public_html/static/js/'));
});
//concat html templates files to js
gulp.task('html', function () {
return gulp.src('./src/**/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(ngTemplates({
module: 'sotos.tmp'
}))
// .pipe(ngmin({dynamic: false}))
// .pipe(uglify())
.pipe(gulp.dest('./src/'));
});
// angularmin
gulp.task('angularmin', function () {
return gulp.src('./dist/js/'+pkg.name+'.js')
.pipe(ngmin({dynamic: false}))
.pipe(uglify())
.pipe(header(banner, { pkg : pkg } ))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./dist/js/'));
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.html, ['html']);
gulp.watch(paths.js, ['scripts']);
});
function autoprefix() {
return autoprefixer({browsers: [
'last 3 versions', 'last 3 Android versions'
]});
}
gulp.task('make', ['sass','html','scripts','angularmin']);
gulp.task('build', ['sass','html','scripts']);
gulp.task('default', ['build','webserver','watch']);