-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (83 loc) · 2.34 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
var history = require('connect-history-api-fallback');
gulp.task('clean', function() {
return gulp.src('./dist/', {read: false})
.pipe(plugins.clean());
});
gulp.task('copy', ['clean'], function() {
return gulp.src([
'app/img/**/*',
'app/views/**/*',
'app/js/**/*',
], {'base': 'app'})
.pipe(gulp.dest('./dist/'));
});
gulp.task('ngAnnotate', ['copy'], function() {
return gulp.src('dist/js/app.js')
.pipe(plugins.ngAnnotate())
.pipe(gulp.dest('dist/js/'));
});
gulp.task('copyFonts', ['clean'], function() {
return gulp.src('app/bower/**/{,*/}*.{woff,woff2,eot,svg,ttf,otf}')
.pipe(plugins.flatten())
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('inject_env', ['clean'], function() {
return gulp.src('app/index.html')
.pipe(plugins.replace(
/\$GOOGLE_ANALYTICS_ID/, '"' + process.env.GOOGLE_ANALYTICS_ID + '"'
))
.pipe(gulp.dest('dist/'));
});
gulp.task('main_css', ['clean'], function() {
return gulp.src('app/css/*.css')
.pipe(plugins.sourcemaps.init())
.pipe(plugins.concat('main.css'))
.pipe(plugins.sourcemaps.write())
.pipe(gulp.dest('dist/css/'));
});
gulp.task('vendor_js', ['clean'], function() {
return gulp.src(mainBowerFiles(['**/*.js']))
.pipe(plugins.concat('vendor.js'))
.pipe(gulp.dest('dist/js/'));
});
gulp.task('vendor_css', ['clean'], function() {
return gulp.src(mainBowerFiles(['**/*.css']))
.pipe(plugins.concat('vendor.css'))
.pipe(gulp.dest('dist/css/'));
});
gulp.task('surge200', ['inject_env'], function() {
return gulp.src(['dist/index.html' ], {'base': 'dist'})
.pipe(plugins.rename('200.html'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('build', [
'copyFonts',
'copy',
'ngAnnotate',
'inject_env',
'vendor_js',
'main_css',
'vendor_css',
'surge200'
]);
gulp.task('connect', ['build'], function() {
plugins.connect.server({
root: 'dist',
port: 3474,
livereload: true,
middleware: function(connect, opt) {
return [history()];
}
});
});
gulp.task('html', function() {
gulp.src('./app/*.html')
.pipe(plugins.connect.reload());
});
gulp.task('watch', function() {
gulp.watch(['./app/*.html'], ['html']);
});
gulp.task('default', ['connect', 'watch']);