This repository was archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
118 lines (105 loc) · 3.26 KB
/
Gulpfile.js
File metadata and controls
118 lines (105 loc) · 3.26 KB
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
var gulp = require('gulp'),
connect = require('gulp-connect'),
jshint = require('gulp-jshint'),
historyApiFallback = require('connect-history-api-fallback'),
inject = require('gulp-inject'),
wiredep = require('wiredep').stream,
templateCache = require('gulp-angular-templatecache'),
gulpif = require('gulp-if'),
minifyCss = require('gulp-minify-css'),
useref = require('gulp-useref'),
uglify = require('gulp-uglify'),
uncss = require('gulp-uncss');
gulp.task('webserver', function(){
connect.server({
root:'./app',
hostname: '0.0.0.0',
port: 9000,
liveReload: true,
middleware: function(connect, opt) {
return [ historyApiFallback ];
}
});
});
gulp.task('dist-server', function(){
connect.server({
root: './dist',
hostname: '0.0.0.0',
port: 9002,
liveReload: true,
middleware: function(connect, opt) {
return [historyApiFallback];
}
});
});
gulp.task('inject', function() {
var sources = gulp.src(['./app/js/**/*.js','./app/styles/**/*.css']);
return gulp.src('index.html', {cwd: './app'})
.pipe(inject(sources, {
read: false,
ignorePath: '/app'
}))
.pipe(gulp.dest('./app'));
});
gulp.task('wiredep', function () {
gulp.src('./app/index.html')
.pipe(wiredep({
directory: './app/lib'
}))
.pipe(gulp.dest('./app'));
});
gulp.task('reload', function(){
gulp.src('./app/**/*.{html,js,css}')
.pipe(connect.reload());
});
gulp.task('jshint', function(){
return gulp.src('./app/js/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('templates', function(){
gulp.src('./app/views/**/*.tpl.html')
.pipe(templateCache({
root: 'views/',
module: 'evaluon.templates',
standalone: true
}))
.pipe(gulp.dest('./app/js/templates'));
});
gulp.task('compress', function(){
gulp.src('./app/index.html')
.pipe(useref.assets())
.pipe(gulpif('*.js', uglify({mangle: false})))
.pipe(gulpif('*.css', minifyCss()))
.pipe(gulp.dest('./dist'));
});
gulp.task('copy', function(){
gulp.src('./app/index.html')
.pipe(useref())
.pipe(gulp.dest('./dist'));
gulp.src('./app/img/**')
.pipe(gulp.dest('./dist/img'));
gulp.src('./app/styles/material-icons/**')
.pipe(gulp.dest('./dist/styles/material-icons'));
gulp.src('./app/styles/material-icons.css')
.pipe(gulp.dest('./dist/styles'));
});
gulp.task('uncss', function(){
gulp.src('./dist/styles/style.min.css')
.pipe(uncss({
html: ['./app/index.html', './app/views/404.tpl.html',
'./app/views/about.tpl.html', './app/views/forgot.tpl.html',
'./app/views/home.tpl.html']
}))
.pipe(gulp.dest('./dist/styles'));
});
gulp.task('watch', function(){
gulp.watch(['./app/**/*.{html,js,css}'], ['reload']);
gulp.watch(['./bower.json'], ['wiredep']);
gulp.watch(['./app/js/**/*.js'], ['inject']);
gulp.watch(['./app/views/**/*.tpl.html'], ['templates']);
});
gulp.task('prepare', ['templates', 'wiredep', 'inject']);
gulp.task('build', ['prepare', 'compress', 'copy']);
gulp.task('default', ['prepare', 'webserver', 'watch']);