-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
91 lines (73 loc) · 2.28 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
var gulp = require('gulp'),
inject = require('gulp-inject'),
watch = require('gulp-watch'),
eslint = require('gulp-eslint'),
concat = require('gulp-concat');
/**
* Build app for development
* Watch new files
* */
gulp.task('default', ['injectScriptsDev'], function () {
var sources = ['./app/**/*.js'],
templates = ['./templates/**/*.html'];
// run first time, than do actions by watchers
gulp.start('injectTemplates');
watch(sources, {events: ['add', 'unlink']}, function () {
gulp.start('injectScriptsDev');
});
watch(templates, {events: ['add', 'change', 'unlink']}, function () {
gulp.start('injectTemplates');
});
});
gulp.task('build', ['injectScriptsBuild']);
/**
* Inject all development files
* */
gulp.task('injectScriptsDev', function (done) {
var target = gulp.src('./index.html');
var sources = gulp.src(
[
'./app/**/*.js',
'./assets/css/**/*.css'
],
{read: false});
target
.pipe(inject(sources, {relative: true}))
.pipe(gulp.dest('./'));
target.on('end', function () {
done();
});
});
gulp.task('lint', function () {
return gulp.src(['app/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('buildApp', ['injectRepo'], function () {
gulp.src('app/**/*.html')
.pipe(gulp.dest('./dist'));
gulp.src('app/**/*.js')
.pipe(concat('app.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('injectTemplates', function () {
gulp.src('index.html')
.pipe(inject(gulp.src(['./templates/**/*.html']), {
starttag: '<!-- inject:templates:{{ext}} -->',
transform: function (filePath, file) {
return file.contents.toString('utf8');
}
}))
.pipe(gulp.dest('./'));
});
gulp.task('injectRepo', function () {
gulp.src('index.html')
.pipe(inject(gulp.src(['./app/repositories/**/*.js']), {
starttag: '<!-- inject:repositories:{{ext}} -->',
transform: function (filePath, file) {
return '<script type="text/javascript">' + file.contents.toString('utf8') + '</script>';
}
}))
.pipe(gulp.dest('./'));
});