forked from rhoegg-things/things-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·120 lines (103 loc) · 2.83 KB
/
gulpfile.js
File metadata and controls
executable file
·120 lines (103 loc) · 2.83 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
119
120
var gulp = require('gulp');
var browserSync = require('browser-sync');
var del = require('del');
var runSequence = require('run-sequence');
var deploy = require('gulp-gh-pages');
var args = require('yargs').argv;
var fs = require('fs');
var karma = require('karma');
var $ = require('gulp-load-plugins')({
rename: {
"gulp-replace-task": "replace"
}
});
gulp.task('configure-environment', function() {
var env = args.env || 'local';
var filename = env + '.json';
var settings = JSON.parse(fs.readFileSync('./config/' + filename, 'utf8'));
gulp.src('app/js/config.js')
.pipe($.replace({
patterns: [
{
match: 'equipmentApi',
replacement: settings.equipmentApi
},
{
match: 'peopleApi',
replacement: settings.peopleApi
}
]
}))
.pipe(gulp.dest('dist/js/'));
});
gulp.task('sass', function() {
var sassPaths = [
'bower_components/foundation-sites/scss',
'bower_components/motion-ui/src'
];
return gulp.src('app/scss/app.scss')
.pipe($.sass({
includePaths: sassPaths
})
.on('error', $.sass.logError))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task('clean', function() {
return del.sync('dist');
});
gulp.task('build-styles', ['sass'], function() {
return gulp.src('app/css/*.css')
.pipe(gulp.dest('dist/css/'));
});
gulp.task('build-scripts', function() {
return gulp.src(['app/js/*.js', '!app/js/config.js'])
.pipe(gulp.dest('dist/js/'));
});
gulp.task('build-html', ['build-scripts', 'build-styles'], function() {
return gulp.src('app/*.html')
.pipe($.useref({
searchPath: ['dist', '.']
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('build-data', function() {
return gulp.src('app/*.json')
.pipe(gulp.dest('dist/'));
});
gulp.task('build-bower', function() {
return gulp.src('bower_components/**/*')
.pipe(gulp.dest('dist/bower_components/'));
});
gulp.task('build', function(callback) {
runSequence(
'clean',
'configure-environment',
['build-bower', 'build-html', 'build-styles', 'build-scripts', 'build-data'],
callback);
});
gulp.task('test', ['build', 'configure-environment'], function(callback) {
new karma.Server({
configFile: __dirname + "/karma.conf.js",
singleRun: true
}, callback).start();
});
gulp.task('serve-reload', ['build'], function() {
browserSync.reload();
});
// watch files for changes and reload
gulp.task('serve', ['build'], function() {
browserSync({
server: {
baseDir: 'dist'
}
});
gulp.watch('app/scss/*.scss', ['sass']);
gulp.watch(['*.html', '*.json', 'css/**/*.css', 'js/**/*.js'], {cwd: 'app'}, ['serve-reload']);
});
gulp.task('deploy-azure', ['build'], function() {
return gulp.src('dist/**/*')
.pipe(deploy({
branch: 'azure'
}));
});